Store UltraGrid layout in temp-table (db table) clob field

Posted by vrtik on 22-Mar-2010 05:22

Hi. Can someone help with this please or show me a better way how to story UltraGrid layout in database.

DEFINE VARIABLE a AS LONGCHAR.

DEFINE TEMP-TABLE tryit NO-UNDO

FIELD cLayout AS CLOB COLUMN-CODEPAGE 'utf-8'.

CREATE tryit.

/* Save Layout */

DEFINE VARIABLE ms AS System.IO.MemoryStream.

ms =

NEW System.IO.MemoryStream().

ultraGrid1:DisplayLayout:SaveAsXml(ms).

DEF VAR obj1 AS System.Text.UTF8Encoding.

obj1 =

NEW System.Text.UTF8Encoding().

a = obj1:GetString(ms:ToArray()).

COPY-LOB FROM a TO tryit.cLayout.

ms:Close().

ms:Dispose().

/* Load Layout */

DEFINE VARIABLE ms2 AS System.IO.MemoryStream.

DEF VAR obj2 AS System.Text.UTF8Encoding.

obj2 =

NEW System.Text.UTF8Encoding().

COPY-LOB FROM tryit.cLayout TO a.

ms2 =

NEW System.IO.MemoryStream(obj2:getbytes(a),0,obj2:getbytecount(a)).

ultraGrid1:DisplayLayout:LoadFromXml(ms2).

ms2:

Close().

ms2:Dispose().

When i try to load layout i'm getting error message : System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.

All Replies

Posted by Admin on 09-Jun-2010 10:47

I've tested your exact code by putting it in a form with two grids with the ability to copy the current layout of the first grid to the second grid (push the button in the attached sample, sample code goes to a folder UltraGridSaveLayout).

I don't get any error on 10.2B01.

[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/26/3022.SaqveLayoutForm.cls.zip:550:0]

[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/26/5722.SaqveLayoutForm.resx.zip:550:0]

Has your grid actually been realized or attached to a bindingSource when you tried?

Posted by vrtik on 10-Jun-2010 05:03

Thank you very much for all your help.

I've just changed version of progress we are using from 10.1A to 10.2B01 and tried again. No error, everything works as expected.

Peter

This thread is closed