Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Displaying different data in datagrid cells using a cellrenderer?

Guest
Apr 01, 2013 Apr 01, 2013

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.

TOPICS
ActionScript
594
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Apr 03, 2013 Apr 03, 2013

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

...
Translate
LEGEND ,
Apr 03, 2013 Apr 03, 2013

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 03, 2013 Apr 03, 2013

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).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 03, 2013 Apr 03, 2013

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:

http://help.adobe.com/en_US/ActionScript/3.0_UsingComponentsAS3/WS5b3ccc516d4fbf351e63e3d118a9c65b32...

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). 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 07, 2013 Apr 07, 2013

Thanks Sinious - diving into this today.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 08, 2013 Apr 08, 2013
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines