We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Speeing up loading data into GridControl

I am using the indexer approach to copy data from a dataset into a GridControl. I have special handling to do and, therefore, cannot use the PopulateValues approach.
However, it is very slow and i am trying to speed it up. I noticed on this forum a recommendation to use the following approach to speed up data copying:

GridStyleInfo style = new GridStyleInfo();
style.CellValue = MyArray[row - 1, col + 1];
grid.Data[row, col] = style.Store;

However, i am storing data in the Tag property of the cell (grid[row,col].Tag) and notice that i cannot set it anymore if i use the GridStyleInfo approach. It is always null. Before i add a hidden column, is there any way to make this faster and use the Tag property? Here''s what i was setting for the cell:

this[rowIndex, colIndex].CellValue = text;
this[rowIndex, colIndex].CellType = CELLTYPE_STATIC;
this[rowIndex, colIndex].ReadOnly = true;

Here is how i have tried to speed it up:
GridStyleInfo style = new GridStyleInfo();
style.CellValue = text;
this.Data[rowIndex, colIndex] = style.Store;
this[rowIndex, colIndex].CellType = CELLTYPE_STATIC;
this[rowIndex, colIndex].ReadOnly = true;

Thanks,
Julie

7 Replies

AD Administrator Syncfusion Team August 16, 2006 10:36 PM UTC

Try this.

GridStyleInfo style = new GridStyleInfo();
style.CellValue = text;
style.CellType = CELLTYPE_STATIC;
style.ReadOnly = true;
style.Tag = someObject;

this.Data[rowIndex, colIndex] = style.Store;


In your loop, do not directly index the grid at all. Doing so, will slow things down.


JL Julie Levy August 17, 2006 04:56 PM UTC

Thanks for your quick response Clay.
Two issues for me with this approach.

1. I tested setting the tag this way and still got a null when i tried to retrieve the Tag using indexing (grid[row,col].Tag). Would i have to retrieve it from the Data? from the style?

2. I actually don''t set the Tag in the loop. It''s not on every cell. Basically, it''s a row marker - i couldn''t find a Tag property on the row level so i''m storing it in one cell''s tag property per row. But, if i figure out the answer to 1., i could re-write things to set it in the loop. Or, do you have any other suggestions about how to store row-level information?

Thanks again,
Julie


JL Julie Levy August 17, 2006 07:00 PM UTC

One more thing. I have to read this tag in the PrepareViewStyleInfo event and am currently using indexing. How do i read the tag without it?

Thanks,
Julie


JL Julie Levy August 17, 2006 07:09 PM UTC

oops, ignore that last question. I see that there''s a style property in the event args. I assume this is the way to go.


JL Julie Levy August 17, 2006 10:30 PM UTC

One more update. I got the tag setting to work and am using this.Model[row, col].Tag to read it instead of this[row, col].Tag ( as well as for reading other style info).

Is this the proper way to read the info? I don''t notice very much performance improvement even though i''ve removed all direct indexing of the grid. Can you give me a list of some of the events which may still be firing so i can check them out.

Thanks,
Julie


AD Administrator Syncfusion Team August 17, 2006 11:19 PM UTC

You should see a noticeable increase in load performance using GridData over an indexer. Here is a sample illustrating this. To load 1000x100 cells with an indexer takes about 10 secs, but directly populating the GridData object takes less than a half a second.

http://www.syncfusion.com/Support/user/uploads/GridData_33cd5c1.zip

I am not sure why the Tag is not being set through the indexer. Are you handling either QueryCellInfo or SaveCellInfo? This might affect the Tag getting saved. If it works OK using th eindexer on the Model, that should not cause any other problems.


JL Julie Levy August 18, 2006 08:45 PM UTC

Thanks Clay, i finally got it going fast. It turned out to be something in my code.

Regarding setting the tag, i still had problems setting it via indexing the grid or indexing the Model if it was set after the style.Store was set on the cell ( unfortunately, i can''t set the tag value at the same time the cellvalue and other properties are set). As long as i set it beforehand, it''s okay. Afterwards, it''s always null - even right after i set it. So i''m setting it before and doing this in the data copy loop to persist it:

GridStyleInfo style = new GridStyleInfo();

style.CellValue = text;
style.CellType = CELLTYPE_STATIC;
style.ReadOnly = true;
style.Trimming = StringTrimming.EllipsisWord;
style.Tag = this.Model[rowIndex, colIndex].Tag;

this.Data[rowIndex, colIndex] = style.Store;

Thanks again for all your help,
Julie

Loader.
Live Chat Icon For mobile
Up arrow icon