0 Replies Latest reply on Mar 29, 2011 12:52 PM by crazycabo

    Manually changing datagrid values, then verifying with a function..

    crazycabo

      flex_example.jpg

      I am simply trying to verify when a user attempts to change a specific value in one the above cells in a given row. If both are = or < 4, the change will take affect. If not, I want to run a function to disallow the change to happen, reverting back to the values before the attempt. I tried to use the "itemEditEnd" property, which makes the most sense to me. It does not work as intended though.

       

      Here is the function I call with the "itemEditEnd" property:

       

      private function verifyCorrectCardCount():void{

           var item:Object = deckGrid.selectedItem;

           var cardName:String = item.name;

           var cardType:String = item.type;

           var setName:String = item.setname;

           var cardRules:String = item.rules;

           var cardNameFromDeck:String;

           var deckCount:int = item.deckCount;

           var sideCount:int = item.sideCount;
                     

           for (var loop:int = 0; loop < deck.length; loop++) {

                cardNameFromDeck = deck.getItemAt(loop).name;

                if (cardName == cardNameFromDeck) {

                     if ((deckCount + sideCount) > 4) {

                          deck.removeItemAt(loop);

                          deck.addItem({name:cardName, type:cardType, setname:setName, rules:cardRules, deckCount:deckCountCheck, sideCount:sideCountCheck});

                     }else {

                     return;

                     }

                }

           }

      }

       

      Note: deckGrid is an arrayCollection used by the dataGrid above.

       

      Maybe timing is the issue. I'm still don't know how all of the dataGrid properties and dispatchers work.