flex - Simple way to call a function inside itemRenderer in a Spark List, from the main application -


I have a main application that contains a list, using a custom item renderer to display the data.

I

While driving the app, we have a list with three people, and have a button, which wants to be able to call function inside the item renderer from the main app is. From the main app, I want to call the myItemRendererFunction () function, in the item's reader, in the list of selected items .

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; S: WindowedApplication xmlns: fx = "http://ns.adobe.com/mxml/2009" xmlns: s = "Library: //ns.adobe.com/flex/spark" xmlns: mx = "Library: // Ns.adobe.com/flex/mx"> & Lt; Fx: script & gt; & Lt ;! [CDATA [Import mx.collections.ArrayCollection; Import mx.events.FlexEvent; [First name: "Piererson"}, {first name: "Peter", last name: "Piererson"}, {first name: "Smith"}, "Bell"}]); Protected Function Check all (): Zero {// Here I want to renderer inside the item of the desired row in the "myItemRendererFunction ()" function // column}]> gt; & Lt; / Fx: script & gt; & Lt; S: layout & gt; & Lt; S: Vertical layout paddingbottom = "10" padding lift = "10" paddingrite = "10" padding = "10" /> & Lt; / S: Layout & gt; & Lt; S: List id = "myList" width = "100%" height = "100%" data provider = "{_ dp}" item renderer = "renderers.FriendDisplayRenderer" /> & Lt; S: Button label = "View all for selected items" Click = "CheckAll ()" /> & Lt; / S: WindowedApplication & gt;   

And now, my item renderer

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; S: item renderer xmlns: fx = "http://ns.adobe.com/mxml/2009" xmlns: s = "library: //ns.adobe.com/flex/spark" xmlns: mx = "library: / /ns.adobe.com/flex/mx "autoDrawBackground =" true "& gt; & Lt; Fx: script & gt; & Lt ;! [CDATA [Public Function myItemRendererFunction (): Zero {chk_1.selected = true; Chk_2.selected = True; Chk_3.selected = true; }] & Gt; & Lt; / Fx: script & gt; & Lt; S: layout & gt; & Lt; S: horizontal lout paddingbottom = "10" padding lift = "10" paddingrite = "10" padding = "10" /> & Lt; / S: Layout & gt; & Lt; S: Label text = "{data.firstname} {data.lastname}" width = "150" /> & Lt; S: check box id = "chk_1" label = "likes hockey" /> & Lt; S: check box id = "chk_2" label = "baseball choice" /> & Lt; S: check box id = "chk_3" label = "football choice" /> & Lt; / S: ItemRenderer & gt;   

Thanks for the help !!!!

Renders that will render based on the data provided.
So what you really need to do, changes the data and render it again.

  [bindable] private var _dp: ArrayCollection = new ArrayCollection ([firstname: "Bob", lastname: "Smith", chk_1: false, chk_2: false, chk_3: false}, {first Name: "Gerard", last name: "Pearson", chk_1: wrong, Chk_2: false, chk_3: false}, {first name: "Peter", last name: "Bell", chk_1: false, chk_2: false, chk_3 : wrong},]); Protected Function Check all (): Zero {// Here I want the "myItemRendererFunction ()" function in the // column, the item renderer of the selected row for each (object in var obj: this._dp) {obj.chk_1 = true ; Obj.chk_2 = true; Obj.chk_3 = true; } This._dp.refresh (); } // Add committedProperties () to this override protected function in your renderer: Zero {chk_1.selected = this.data.chk_1; Chk_2.selected = this.data.chk_2; Chk_3.selected = this.data.chk_3; }    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -