DataGrid's are cool, but yeash I've run into a lot of problems with them. I've put together two *real simple* online demonstrations that illustrate the behavior I'm seeing with a grid. I'd love for someone more experienced to check out these two examples and offer any insight or solution.
http://www.trajiklyhip.com/flex/gridexample/DataGridExample1.html
This is a simple grid that uses a custom Checkbox item renderer written in AS3. Clicking the submit button will display whether or not each Checkbox is selected. Make some changes to the boxes, de-selecting a few or an entire column and then click the submit button to see the selected value. The Alert box usually displays the right info the first time through, but after you've gone through a few rounds of selecting and de-selecting some of the boxes it will not show you the correct true/false value of each box.
http://www.trajiklyhip.com/flex/gridexample/DataGridExample2.html
This is another simple grid that is the same as the previous one only with more rows of data to make the DataGrid scroll. De-select the first "Group Owner" Checkbox (row 1 with the ID = 12) and then click use the grid scroll bar to scroll up and down. As you scroll, other Checkboxes are selected and deselected at random.
Incidentally, if you right-click the DataGridExample1 movie you can view the source to see what I'm doing.














<a href="http://www.jessewarden.com/archives/2006/10/checkb...;
IconRenderer, BackgroundColorRenderer, CheckBoxRenderer:
http://philflash.inway.fr/flex/dgsimple
CheckBoxRenderer, ComboBoxRenderer, ColorPickerRenderer:
http://philflash.inway.fr/flex/dgRendererSimple
Philippe
For more info on itemRenderers and recycling rows, the best article I know of is by Alex Harui on http://blogs.adobe.com/aharui. Search for his articles on itemRenderers.
Here's some additional information that should help you get started. Both links are to Adobe Flex live docs:
http://tinyurl.com/4xz76d
http://tinyurl.com/4axywy
i am facing the same problem with datagrid scroll and checkbox renderers..
if possible can u post the solution.
Thanks
do not override this function. If you want to override it call the parent one
"super.clickHandler(event)"
I'm very new to Flex programming so please let me ask two (maybe simple) questions regarding your example:
1. How can I center the Checkboxes inside the column?
2. How can I change the font size in the DataGrid? (I used Strings instead of Integers but I think that doesn't matter)
Thanks in advance.
To make checkbox center, override the updateDisplayList function in renderer file
override protected function updateDisplayList(w:Number, h:Number):void
{
super.updateDisplayList(w, h);
if (listData is DataGridListData)
{
var n:int = numChildren;
for (var i:int = 0; i < n; i++)
{
var c:DisplayObject = getChildAt(i);
if (!(c is TextField))
{
c.x = (w - c.width) / 2;
c.y = 0;
}
}
}
}
when my dataprovider value representing the checkbox was
not initialized to eiter true or false. In debugging it was showing
up as undefined.
I now set the value to false every time I add a row and there
are no more strange scrolling problems
I have created a check box item renderer for my datgrid.
I will update the arraycollection by checking or unchecking
the checkbox. I will submit the data to backend and I will assign the
dataprovider with updated dataprovider. My data is getting
updated but the some checkboxes are appearing as checked.
They are not getting reinitialized.
Can any body help me solve this issue.Its urgent
Thanks
vin
thanks in advance
vin
in my item-renderer there was an image which i used to hide when the item is selected
so when I scroll after selecting an item, one of the image of the coming renderes
used to be invisible.
It bugged me a alot but then I do the following in the item-renderer code
override public function set data(value:Object):void
{
super.data=value;
foldername.text= value.@name;
if(this.owner is MyList){
var o:Object=(this.owner as MyList).SelectedData;
if(o!=value){
btnArrow.visible=true;
}else btnArrow.visible=false;
}
}
//explanation
1. MyList is my list component simply just extending List.
2. I defined a variable
var SelectedData:Object in MyList.
which stores the data of the currently selected item.
I am having the exact same problem you had in 2nd example
I am using Flex 3.2
Would you like to share with me the workaround you did?