Loading ...
Sorry, an error occurred while loading the content.

Re: Looping through a DataGrid and check a custom column value

Expand Messages
  • valdhor
    I am a little swamped at the moment but I am fairly sure I can figure this out. Just give me a couple days.
    Message 1 of 7 , Apr 5 5:50 AM
    View Source
    • 0 Attachment
      I am a little swamped at the moment but I am fairly sure I can figure this out. Just give me a couple days.

      --- In flexcoders@yahoogroups.com, Wally Kolcz <wkolcz@...> wrote:
      >
      > I am trying to use a custom itemRenderer (checkboxes) for columns in a
      > datagrid. When the submission function is fired I need to loop through
      > the DataGrid by row and check to see if either and/or box checkboxes are
      > selected and use that in an IF statement. I am using the dataprovider
      > ('pets') as a length for the for loop, but I don't know how to A.) check
      > each row on a loop and B.) Check to see if the value of the column is
      > true or false. I can't check the dataprovider by row since the 2 columns
      > are added outside of the dataprovider.
      >
      > Here is my DataGrid:
      > <mx:DataGrid width="100%" height="100%" dataProvider="{pets}" id="exportDG">
      > <mx:columns>
      > <mx:DataGridColumn id="pf" headerText="Petfinder" width="65"
      > itemRenderer="com.petpalmanager.views.IR.UploadCheckBox"
      > rendererIsEditor="true" />
      > <mx:DataGridColumn id="aap" headerText="Adoptapet" width="65"
      > itemRenderer="com.petpalmanager.views.IR.UploadCheckBox"
      > rendererIsEditor="true"/>
      > <mx:DataGridColumn headerText="Pet Name" width="150" dataField="petName" />
      > <mx:DataGridColumn headerText="Pet Type" width="90" dataField="pType" />
      > <mx:DataGridColumn headerText="Breed/Species" width="200"
      > labelFunction="getBreeds" wordWrap="true" />
      > <mx:DataGridColumn id="descript" headerText="Description"
      > itemRenderer="mx.controls.TextArea" rendererIsEditor="true" />
      > <mx:DataGridColumn dataField="petID" visible="false" />
      > </mx:columns>
      > </mx:DataGrid>
      >
      > Here is the itemRenderer:
      > <s:MXItemRenderer 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">
      > <fx:Script>
      > <![CDATA[
      > [Bindable] public var isSelected:Boolean = new Boolean;
      >
      > private function updateSelected(status:Boolean):void {
      > isSelected = status;
      > }
      > ]]>
      > </fx:Script>
      >
      > <mx:CheckBox id="upload" horizontalCenter="0" verticalCenter="0"
      > change="updateSelected(upload.selected);"/>
      > </s:MXItemRenderer>
      >
      > Here is the start of the function for the loop:
      > private function exportPets():void {
      > for (var i:int = 0; i < pets.length; i++){
      >
      > }
      > }
      >
      > Thanks for any help you can offer.
      >
    • Wally Kolcz
      Sorry I forgot to update this, but I got it working after the first response.
      Message 2 of 7 , Apr 5 5:57 AM
      View Source
      • 0 Attachment
        Sorry I forgot to update this, but I got it working after the first response.

        On Tue, Apr 5, 2011 at 8:50 AM, valdhor <valdhorlists@...> wrote:
         

        I am a little swamped at the moment but I am fairly sure I can figure this out. Just give me a couple days.



        --- In flexcoders@yahoogroups.com, Wally Kolcz <wkolcz@...> wrote:
        >
        > I am trying to use a custom itemRenderer (checkboxes) for columns in a
        > datagrid. When the submission function is fired I need to loop through
        > the DataGrid by row and check to see if either and/or box checkboxes are
        > selected and use that in an IF statement. I am using the dataprovider
        > ('pets') as a length for the for loop, but I don't know how to A.) check
        > each row on a loop and B.) Check to see if the value of the column is
        > true or false. I can't check the dataprovider by row since the 2 columns
        > are added outside of the dataprovider.
        >
        > Here is my DataGrid:
        > <mx:DataGrid width="100%" height="100%" dataProvider="{pets}" id="exportDG">
        > <mx:columns>
        > <mx:DataGridColumn id="pf" headerText="Petfinder" width="65"
        > itemRenderer="com.petpalmanager.views.IR.UploadCheckBox"
        > rendererIsEditor="true" />
        > <mx:DataGridColumn id="aap" headerText="Adoptapet" width="65"
        > itemRenderer="com.petpalmanager.views.IR.UploadCheckBox"
        > rendererIsEditor="true"/>
        > <mx:DataGridColumn headerText="Pet Name" width="150" dataField="petName" />
        > <mx:DataGridColumn headerText="Pet Type" width="90" dataField="pType" />
        > <mx:DataGridColumn headerText="Breed/Species" width="200"
        > labelFunction="getBreeds" wordWrap="true" />
        > <mx:DataGridColumn id="descript" headerText="Description"
        > itemRenderer="mx.controls.TextArea" rendererIsEditor="true" />
        > <mx:DataGridColumn dataField="petID" visible="false" />
        > </mx:columns>
        > </mx:DataGrid>
        >
        > Here is the itemRenderer:
        > <s:MXItemRenderer 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">
        > <fx:Script>
        > <![CDATA[
        > [Bindable] public var isSelected:Boolean = new Boolean;
        >
        > private function updateSelected(status:Boolean):void {
        > isSelected = status;
        > }
        > ]]>
        > </fx:Script>
        >
        > <mx:CheckBox id="upload" horizontalCenter="0" verticalCenter="0"
        > change="updateSelected(upload.selected);"/>
        > </s:MXItemRenderer>
        >
        > Here is the start of the function for the loop:
        > private function exportPets():void {
        > for (var i:int = 0; i < pets.length; i++){
        >
        > }
        > }
        >
        > Thanks for any help you can offer.
        >


      • ClayB
        Hi, Can you post your solution? Facing the same dilemma...
        Message 3 of 7 , May 10, 2011
        View Source
        • 0 Attachment
          Hi,
          Can you post your solution? Facing the same dilemma...

          --- In flexcoders@yahoogroups.com, Wally Kolcz <wkolcz@...> wrote:
          >
          > Sorry I forgot to update this, but I got it working after the first
          > response.
          >
          > On Tue, Apr 5, 2011 at 8:50 AM, valdhor <valdhorlists@...> wrote:
          >
          > >
          > >
          > > I am a little swamped at the moment but I am fairly sure I can figure this
          > > out. Just give me a couple days.
          > >
          > >
          > > --- In flexcoders@yahoogroups.com, Wally Kolcz <wkolcz@> wrote:
          > > >
          > > > I am trying to use a custom itemRenderer (checkboxes) for columns in a
          > > > datagrid. When the submission function is fired I need to loop through
          > > > the DataGrid by row and check to see if either and/or box checkboxes are
          > > > selected and use that in an IF statement. I am using the dataprovider
          > > > ('pets') as a length for the for loop, but I don't know how to A.) check
          > > > each row on a loop and B.) Check to see if the value of the column is
          > > > true or false. I can't check the dataprovider by row since the 2 columns
          > > > are added outside of the dataprovider.
          > > >
          > > > Here is my DataGrid:
          > > > <mx:DataGrid width="100%" height="100%" dataProvider="{pets}"
          > > id="exportDG">
          > > > <mx:columns>
          > > > <mx:DataGridColumn id="pf" headerText="Petfinder" width="65"
          > > > itemRenderer="com.petpalmanager.views.IR.UploadCheckBox"
          > > > rendererIsEditor="true" />
          > > > <mx:DataGridColumn id="aap" headerText="Adoptapet" width="65"
          > > > itemRenderer="com.petpalmanager.views.IR.UploadCheckBox"
          > > > rendererIsEditor="true"/>
          > > > <mx:DataGridColumn headerText="Pet Name" width="150" dataField="petName"
          > > />
          > > > <mx:DataGridColumn headerText="Pet Type" width="90" dataField="pType" />
          > > > <mx:DataGridColumn headerText="Breed/Species" width="200"
          > > > labelFunction="getBreeds" wordWrap="true" />
          > > > <mx:DataGridColumn id="descript" headerText="Description"
          > > > itemRenderer="mx.controls.TextArea" rendererIsEditor="true" />
          > > > <mx:DataGridColumn dataField="petID" visible="false" />
          > > > </mx:columns>
          > > > </mx:DataGrid>
          > > >
          > > > Here is the itemRenderer:
          > > > <s:MXItemRenderer 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">
          > > > <fx:Script>
          > > > <![CDATA[
          > > > [Bindable] public var isSelected:Boolean = new Boolean;
          > > >
          > > > private function updateSelected(status:Boolean):void {
          > > > isSelected = status;
          > > > }
          > > > ]]>
          > > > </fx:Script>
          > > >
          > > > <mx:CheckBox id="upload" horizontalCenter="0" verticalCenter="0"
          > > > change="updateSelected(upload.selected);"/>
          > > > </s:MXItemRenderer>
          > > >
          > > > Here is the start of the function for the loop:
          > > > private function exportPets():void {
          > > > for (var i:int = 0; i < pets.length; i++){
          > > >
          > > > }
          > > > }
          > > >
          > > > Thanks for any help you can offer.
          > > >
          > >
          > >
          > >
          >
        • Wally Kolcz
          After I returned a query from my database I basically I set extra values in the ArrayCollection for the check boxes to false that use it as my datasource.
          Message 4 of 7 , May 11, 2011
          View Source
          • 0 Attachment
            After I returned a query from my database I basically I set extra values in the ArrayCollection for the check boxes to false that use it as my datasource. Then, in the itemrenderer, I updated those values based on the checkbox.selected. If you need code examples, let me know.

            On Tue, May 10, 2011 at 9:00 PM, ClayB <bornecw@...> wrote:
             

            Hi,
            Can you post your solution? Facing the same dilemma...



            --- In flexcoders@yahoogroups.com, Wally Kolcz <wkolcz@...> wrote:
            >
            > Sorry I forgot to update this, but I got it working after the first
            > response.
            >
            > On Tue, Apr 5, 2011 at 8:50 AM, valdhor <valdhorlists@...> wrote:
            >
            > >
            > >
            > > I am a little swamped at the moment but I am fairly sure I can figure this
            > > out. Just give me a couple days.
            > >
            > >
            > > --- In flexcoders@yahoogroups.com, Wally Kolcz <wkolcz@> wrote:
            > > >
            > > > I am trying to use a custom itemRenderer (checkboxes) for columns in a
            > > > datagrid. When the submission function is fired I need to loop through
            > > > the DataGrid by row and check to see if either and/or box checkboxes are
            > > > selected and use that in an IF statement. I am using the dataprovider
            > > > ('pets') as a length for the for loop, but I don't know how to A.) check
            > > > each row on a loop and B.) Check to see if the value of the column is
            > > > true or false. I can't check the dataprovider by row since the 2 columns
            > > > are added outside of the dataprovider.
            > > >
            > > > Here is my DataGrid:
            > > > <mx:DataGrid width="100%" height="100%" dataProvider="{pets}"
            > > id="exportDG">
            > > > <mx:columns>
            > > > <mx:DataGridColumn id="pf" headerText="Petfinder" width="65"
            > > > itemRenderer="com.petpalmanager.views.IR.UploadCheckBox"
            > > > rendererIsEditor="true" />
            > > > <mx:DataGridColumn id="aap" headerText="Adoptapet" width="65"
            > > > itemRenderer="com.petpalmanager.views.IR.UploadCheckBox"
            > > > rendererIsEditor="true"/>
            > > > <mx:DataGridColumn headerText="Pet Name" width="150" dataField="petName"
            > > />
            > > > <mx:DataGridColumn headerText="Pet Type" width="90" dataField="pType" />
            > > > <mx:DataGridColumn headerText="Breed/Species" width="200"
            > > > labelFunction="getBreeds" wordWrap="true" />
            > > > <mx:DataGridColumn id="descript" headerText="Description"
            > > > itemRenderer="mx.controls.TextArea" rendererIsEditor="true" />
            > > > <mx:DataGridColumn dataField="petID" visible="false" />
            > > > </mx:columns>
            > > > </mx:DataGrid>
            > > >
            > > > Here is the itemRenderer:
            > > > <s:MXItemRenderer 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">
            > > > <fx:Script>
            > > > <![CDATA[
            > > > [Bindable] public var isSelected:Boolean = new Boolean;
            > > >
            > > > private function updateSelected(status:Boolean):void {
            > > > isSelected = status;
            > > > }
            > > > ]]>
            > > > </fx:Script>
            > > >
            > > > <mx:CheckBox id="upload" horizontalCenter="0" verticalCenter="0"
            > > > change="updateSelected(upload.selected);"/>
            > > > </s:MXItemRenderer>
            > > >
            > > > Here is the start of the function for the loop:
            > > > private function exportPets():void {
            > > > for (var i:int = 0; i < pets.length; i++){
            > > >
            > > > }
            > > > }
            > > >
            > > > Thanks for any help you can offer.
            > > >
            > >
            > >
            > >
            >


          Your message has been successfully submitted and would be delivered to recipients shortly.