1
votes

I create a datagrid with inline itemrenderer. The renderer is a dropdownlist. When dropdowlist value change, I'd like to update dataprovider but I didn't found how to do that. Can you help me?

Thanks

[Bindable] private var DP_PRAT_INIT:ArrayCollection;

<s:DataGrid id="dgTuVous" fontWeight="normal" 
                                        dataProvider="{DP_PRAT_INIT}"
                                        width="100%" height="100%" 
                                        horizontalScrollPolicy="on"
                                        fontSize="10"

                                        >
                                <s:columns>
                                    <s:ArrayList>
                                        <s:GridColumn dataField="prInitiales" width="40" headerText="Prat" />
                                        <s:GridColumn  width="75" dataField="prTuVous"
                                                      headerText="Tu/Vous" editable="true">
                                            <s:itemRenderer>
                                                <fx:Component>
                                                    <s:GridItemRenderer>
                                                        <fx:Script>
                                                            <![CDATA[
                                                                import spark.events.IndexChangeEvent;



                                                                protected function ddlTuVous_changeHandler(event:IndexChangeEvent):void
                                                                {

                                                                    DP_PRAT_INIT[ddlTuVous.selectedIndex].prTuVous=ddlTuVous.selectedItem;

                                                                    trace ("ddlTuVous.selectedItem" +ddlTuVous.selectedItem) ;

                                                                }

                                                            ]]>
                                                        </fx:Script>
                                                        <s:DropDownList width="100%" selectedIndex="1" id="ddlTuVous"
                                                                        change="ddlTuVous_changeHandler(event)">
                                                            <s:dataProvider>
                                                                <s:ArrayList>
                                                                    <fx:String>Tu</fx:String>
                                                                    <fx:String>Vous</fx:String>
                                                                </s:ArrayList>
                                                            </s:dataProvider>
                                                        </s:DropDownList>
                                                    </s:GridItemRenderer>
                                                </fx:Component>
                                            </s:itemRenderer>



                                        </s:GridColumn>

                                    </s:ArrayList>
                                </s:columns>
                            </s:DataGrid>
1
The answer should be in these docs on using itemEditors w/ the Spark DataGrid: help.adobe.com/en_US/flex/using/… - JeffryHouser

1 Answers

1
votes

You reference the host control with the outerDocument property... so you would call outerDocument.DP_PRAT_INIT if you want to access that array. BUT, that array is private, so you have to make it public. Or, you can make a public function that you can call on outerDocument but ... yuck.

If I am understanding your code properly, you should access the data property of the GridItemRenderer which is the same as outerDocument.DP_PRAT_INIT[ddlTuVous.selectedIndex] except that it is better because you don't have possible index mismatches...

So, what you really want is:

data.prTuVous = ddlTuVous.selectedItem;