Welcome, Guest
  • Author Topic: my data grid component does not update  (Read 6316 times)

    saumya

    • Senior Programmer
    • ****
    • Posts: 496
      • View Profile
      • currently active
      • Email
    my data grid component does not update
    « on: 03/01/07, 07:25 »
    hi,
    I was trying to put some data into datagrid, but its not showing up !!
    the code is as below
    [as]
    var myXML : XML = new XML ();
       myXML.load ("addressBook.xml");
       myXML.onLoad = function (ok)
       {
          if (ok)
          {
             aTotalAddresses = this.firstChild.childNodes;
             var totalNoOfAddress : Number = aTotalAddresses.length;
             submit_btn.enabled = true;
             //display data
             view_grid.addColumn ("Name");
             view_grid.addColumn ("Phone");
             view_grid.addColumn ("Address");
             var item_obj:Object = {Name:"personData[0]",Phone:"personData[2]",Address:"personData[1]"};
             view_grid.addItem(item_obj);
             for (var i = 0; i < aTotalAddresses.length; i ++)
             {
                   var personData=aTotalAddresses;
                   //view_grid.
                   var item_obj:Object = {Name:"one", Phone:"two",Address:"three"};
                   view_grid.addItem(item_obj);
                   view_grid.refresh();
             }
          }
       }
    [/as]
    « Last Edit: 03/02/07, 06:42 by saumya »

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: my data grid component does not update
    « Reply #1 on: 03/02/07, 02:25 »
    żIs walking the loop, or in other words, have aTotalAddresses some value?
    Also usually there's no need to refresh the view, but if you do, move the statement outside the for loop and use redraw (the only refresh method I know is for the Tree component)

    Jorge

    saumya

    • Senior Programmer
    • ****
    • Posts: 496
      • View Profile
      • currently active
      • Email
    Re: my data grid component does not update
    « Reply #2 on: 03/02/07, 02:35 »
    thanks Jorge,
    the problem was with the "aTotalAddresses".I was not getting the value only.

    Now, I am getting the data for the first time and everything is fine.But second time I want to show the additional data it is going through that for loop again and creating another set of 3 columns. Is there a way where I can reset the datagrid to the initial value I mean I need to recreate the Datagrid all over again. Since it is on the stage, I can not remove it and recreate another object of it :( .

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: my data grid component does not update
    « Reply #3 on: 03/02/07, 02:44 »
    You want to show aditional data in the same datagrid? Clearing previous data?

    Jorge

    saumya

    • Senior Programmer
    • ****
    • Posts: 496
      • View Profile
      • currently active
      • Email
    Re: my data grid component does not update
    « Reply #4 on: 03/02/07, 02:56 »
    yes

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: my data grid component does not update
    « Reply #5 on: 03/02/07, 05:56 »
    Then write another function or put some conditional in the addColumn part

    Jorge

    saumya

    • Senior Programmer
    • ****
    • Posts: 496
      • View Profile
      • currently active
      • Email
    Re: my data grid component does not update
    « Reply #6 on: 03/02/07, 06:46 »
    hi jorge,
    thank you for the input.
    I have made the changes. Now the making of the component is at another place, so thats not a problem now.

    But I am stuck at updating the data.when I put my new data, it is taking the old datas and another set of old and new datas. Is it possible to clean up the data grid to nodata whenever required?

    thanks

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: my data grid component does not update
    « Reply #7 on: 03/02/07, 09:17 »
    Try myDataGrid.removeAllColumns()

    Jorge

    saumya

    • Senior Programmer
    • ****
    • Posts: 496
      • View Profile
      • currently active
      • Email
    Re: my data grid component does not update
    « Reply #8 on: 03/02/07, 12:59 »
    Thank you Jorge.
    I have made some code re sampling to make the grid work.Now it does not need to be re created. But I will definitely give your option a try to know whether it is workable.