1 Reply Latest reply on Feb 25, 2011 8:04 AM by landar

    Update a single cell value in datagrid

    A.kameshwaran

      Hi,

       

           I want to update a single cell value in a datagrid, is this possible?

      here is the code from adobe for replaceItemAt example:

       

      my_dg.setSize(140, 100);
      my_dg.move(10, 40);

      replace_button.move(10, 10);

      // Set up sample data.
      var myDP_array:Array = new Array();
      myDP_array.push({name:"Clark", score:3135});
      myDP_array.push({name:"Bruce", score:403});
      myDP_array.push({name:"Peter", score:25});
      my_dg.dataProvider = myDP_array;

      // Create listener object.
      var buttonListener:Object = new Object();
      buttonListener.click = function(evt_obj:Object) {
      //Replace previous value
      var prevValue_obj:Object = my_dg.replaceItemAt(2, {name:"Frank", score:949});
      my_dg.selectedIndex = 2;
      };
      // Add button listener.
      replace_button.addEventListener("click", buttonListener);


      what I want to do is just replace the score with out doing anything to the name

      Regards,
      Kameshwaran A.


        • 1. Re: Update a single cell value in datagrid
          landar

          I would think you could operate directly on the provider array and change only the score.

          Something like:

           

          myDP_array[index].score = newScore;

           

          You need to determine the "index" and supply the "newScore" number.

           

          You might have to refresh the dataGrid to show the new results by again setting the

          my_dg.dataProvider = myDP_array;