5 Replies Latest reply on Aug 10, 2011 9:18 AM by nikos101

    ItemEditor valueCommit when editing in a spark datagrid

    nikos101 Level 2

      I'm trying to get me head round this ItemEditor stuff when editing in a spark datagrid but am having problems

       

      I tried to set a flag in the data provider if something has changed. but the value commit doesn't get fired when the user changes a value:

       

           <GridColumn  width="140" headerText="Margin (disabled)"  headerText.editMode="Margin (editing)" dataField="margin"  editable="false"  editable.editMode="true"  >
                          <itemEditor>
                              <fx:Component>
                                  <DefaultGridItemEditor>
                                      <valueCommit>
                                          <![CDATA[
                                          this.data.isModifiedClientSide = 1;
                                          ]]>
                                      </valueCommit>
                                  </DefaultGridItemEditor>
                              </fx:Component>
                          </itemEditor>
                         
                      </GridColumn>

       

       

      what do you think?

        • 1. Re: ItemEditor valueCommit when editing in a spark datagrid
          Amy Blankenship Level 4

          Does it fire when the editor closes (i.e., you click another row or column)?

          • 2. Re: ItemEditor valueCommit when editing in a spark datagrid
            nikos101 Level 2

            Nope

             

            the code for valueCommit is held in UIcomponent, and the grid listens for this:

             

            grid.addEventListener(FlexEvent.VALUE_COMMIT, grid_valueCommitHandler);

             

             

            any ideas?

            • 3. Re: ItemEditor valueCommit when editing in a spark datagrid
              Amy Blankenship Level 4

              valueCommit is not a bubbling event, so you probably need to listen to the specific component within the itemEditor that is capturing the text input.

              • 4. Re: ItemEditor valueCommit when editing in a spark datagrid
                nikos101 Level 2

                I frequently do this for my grids maybe the datagrid has this fucntionality built in to detect changes made by users to rows?

                 

                Should I make a custom component that extends?

                 

                my current solution is to do this:

                 

                 

                <GridColumn  width="140" headerText="Margin (disabled)" headerText.editMode="Margin (editing)" dataField="margin"  editable="false"  editable.editMode="true"  >
                                    <itemEditor>
                                        <fx:Component>
                                           
                                            <DefaultGridItemEditor>
                                                <fx:Script>
                                                    <![CDATA[
                                                        override public function set value(newValue:Object):void
                                                        {
                                                            textArea.text = newValue != null ? newValue.toString() : "";
                                                            this.data.isModifiedClientSide = 1;
                                                        }
                                                    ]]>
                                                </fx:Script>
                                               
                                           
                                            </DefaultGridItemEditor>
                                        </fx:Component>
                                    </itemEditor>
                                   
                                </GridColumn>

                • 5. Re: ItemEditor valueCommit when editing in a spark datagrid
                  nikos101 Level 2

                  I would also like to change the background of the textArea inside the DefaultGridItemEditor class, but I can't seem to do this:

                   

                  Can you think of a better way?

                   

                      <DefaultGridItemEditor>
                                                  <fx:Script>
                                                      <![CDATA[
                                                          override public function set value(newValue:Object):void
                                                          {
                                                              textArea.text = newValue != null ? newValue.toString() : "";
                                                              this.data.isModifiedClientSide = 1;
                                                              textArea.contentBackgroundColor = 0xffdddd;
                                                             
                                                          }
                                                      ]]>
                                                  </fx:Script>
                                                 
                                             
                                              </DefaultGridItemEditor