Hello,
I have a grid that is loading thumbnail images into cells in each row. When there are thousands of rows, performance is pretty slow. Is there a way to fill a cell or row only when it is displayed? I see there is a LoadOnDemand property for the Web grid, is there an equivalent for Win?
Can someone give any tips on how to implement something like this?
Thanks for the help!
Sean.
Hi Sean,
Where are the images coming from? Are they stored in the data source as actual images? Is the column's DataType Image? Or are the images coming from some sort of lookup and you using the Appearance on the cell to supply the image?
We are looking up the images on the file system and loading them in using the cell Appearance.
Hi Mike,
I'm getting closer. The key for the image is the value of the cell that the image should be displayed in. How do I access that info in the CreationFilter class?
Thanks,
OK, found that I can access both the Row and Cell from the CellUIElement. Making good progress.
How do I know whether to set the image in BeforeCreateChildElements or AfterCreateChildElements?
Hi,
You do not need to create your own ImageUIElement class. What you should do is create a sort've "dummy" image that is the same size as your real thumbnails and then assign this image to the Appearance of the cell. The image can be completely blank (solid color) or even transparent. This will have the effect of creating an ImageUIElement in the cell already, which makes your CreationFilter a lot simpler. Now you don't have to worry about creating, adding, or positioning elements. All you have to do is examine the ImageUIElement which is already there and change it's Image property.
If you do that, then you will want to use AfterCreateChildElements. You can do this in one of two ways. You can either trap for the parent element which contains the ImageUIElement. In which case, you get the element and use GetDescendant to get the ImageUIElement from it. Or.. you can trap for when parent is an ImageUIElement and use GetContext to get the UltraGridCell from that. I'd probably go with the latter approach.
Once you have the ImageUIElement and the cell, it's easy. You examine the value of the cell and set the Image property on the ImageUIElement accordingly.
You're right, I did not need a custom ImageUIElement class. I had already created the "standard" implementation with adding and positioning the elements, so I stayed with that. It is working great. The image cache idea was another winner, working perfectly.
Mike, a big thanks to you for all your help! I was able to greatly improve the performance of our application, my boss is very pleased! Thanks!
Great. Glad you got it all sorted out. :)