Copy link to clipboard
Copied
Gidday guys
I'm populating a datagrid using SQLite. Some SQL columns contain 1 or 0 as booleans, and I want to display this as a bullet point in my datagrid.
Currently I have a conditional that checks for a 1, and if found, displays the bullet point. I figure there must be a better way, but am unsure how to do this with cellrenderers. I get how to add components using cellrenderers, but is there a way to replace the cell display with another character (without actually changing the data of the dataprovider) ?
Cheers for taking a look.
It would be better performance to draw a simple shape rather than a TextField with a single character in it. To do so, yes you'd need to override the cell renderer. I often choose the latter but usually use GPU-driven components like FeathersUI components.
If you have an excessively large amount of data and/or are on a device and want to do this because you're getting poor performance, that's a good usage of your time. Also if you just want to learn how to do it just to do it, that's can also be
...Copy link to clipboard
Copied
What's wrong with your first solution? Are you trying to replace a TextField with a Sprite in the case a boolean value is returned in the dot column for performance reasons? Some other reason?
Copy link to clipboard
Copied
I just figured that a cellrenderer solution would make for better performance - not that there's a performance issue at the moment. If you think the conditional I have in is an ok way to do it, I'll keep it.
The SQL stores 1 and 0 for my booelans, but I don't want to display 1 or 0 in the datagrid - just leave it empty for 0, and • for 1 (alt-0149).
Copy link to clipboard
Copied
It would be better performance to draw a simple shape rather than a TextField with a single character in it. To do so, yes you'd need to override the cell renderer. I often choose the latter but usually use GPU-driven components like FeathersUI components.
If you have an excessively large amount of data and/or are on a device and want to do this because you're getting poor performance, that's a good usage of your time. Also if you just want to learn how to do it just to do it, that's can also be a good usage, if you complete your work on time. However if it's for desktop and/or the data is pretty minimal (few dozen rows up to a hundred or so, with a nominal amount of columns), it's probably not worth your time.
I'm sure you have this link but:
All component cellrenderers tend to be the same (because larger components use smaller components and the architecture lines up). The difference is in making sure your renderer supports the data it's provided. If you need only a TextField and/or a bullet, that's pretty easy. Most components (like lists) support icons and you'll need to make sure you provide the complete implementation of all data scenarios in your cellrenderer.
Pay attention to cell dequeue techniques on some components. If all cells commonly have only text, cells aren't destroyed and recreated as the list scrolls. The data is resent to the cell and the cell has a chance to simply update itself rather than recreate itself from scratch. This offers a big performance increase not having to destroy and recreate needlessly. It can also really confuse people when cells start appearing empty as you scroll (because the cell construction methods aren't run).
Copy link to clipboard
Copied
Thanks Sinious - diving into this today.
Copy link to clipboard
Copied
You're welcome and good luck! If you get a chance, check out http://www.feathersui.com for some extremely GPU (via Stage3D/Starling) components. But sorry, they don't have a datagrid yet.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now