4 Replies Latest reply on Jul 31, 2006 6:36 PM by isml

    Problems about DataGrid Item Render in Flex 2.0

    isml
      Actually, i think i have been familiar with cell renderer in Flex 1.5. Now in Flex 2.0, i am a newer again. I could know from the change of the name :) (From cell renderer to item renderer).
      After reading the docs and some samples, finally i understand how to make some easy use, and even know implement IDropInListItemRenderer for some advanced use. But i still have some problems that i can not work it out.
      1. editFiled()
      It is a method in Flex 1.5, but very useful.if i modify an attribute of object, using this method would automatically trigger change event to update the datagrid, but i did not find the corresponding method in Flex 2.0
      2.header renderer
      It has changed much, i think. Mainly it seems to refresh much more frequently than original. It is like that even an item is updated, the header will be refreshed.
      3.data property.
      I mean the override function set data():
      it seems to always be called twice.(Header renderer is the same).

      Thanks in advance.
        • 1. Re: Problems about DataGrid Item Render in Flex 2.0
          peterent Level 2
          You no longer need editField. Just change the item in your dataProvider and call itemUpdated and pass the item:

          var item:MyObject = dp.getItemAt( someIndex ) as MyObject;
          item.city = "San Francisco";
          dp.itemUpdated(item);

          The headerRenderer has changed and it does refresh more frequently. We are looking into that.

          The set data function is called more frequently, that's true. There are different phases in the Flex framework which update it. You have to check for null values as well.
          • 2. Re: Problems about DataGrid Item Render in Flex 2.0
            isml Level 1
            Thanks for your continuous help.
            Actually, i met some migration issuses about the headerRenderer.
            Now I have a datagird, one of whose columns is rendered using a CheckBox control. And i also renderer its header to provide some convenience. Actually, i put a CheckBox on the header, it is for "Select All" use.
            As the SetValue function of renderer file in Flex 1.5 seems to be called only once, I do not do any additional job. But I find it can not work in Flex 2.0. I click the "Select All" checkbox on the header, it is refreshed to be unselected state again. I know this is because Set Data function is called many times. So I try to use a variable to save the selection state, and reset the CheckBox in the Set Data function. At first, i declare it as a private variable in the renderer file, it fails to work. Finally, i find a ugly way to solve the problem. I declare it in the main file (I mean the mxml file that contains <mx:Application>), and in the renderer file, I import mx.core.Application package, and use Application.application.variable to reference it , and it really works.

            I wonder if it is a recommended way or there should be a better solution.

            Thanks.
            • 3. Re: Problems about DataGrid Item Render in Flex 2.0
              peterent Level 2
              Continue to use the method you discovered. The headerRenderer is not being refreshed - it is being recreated. I am not sure why at this point, but I am investigating.
              • 4. Re: Problems about DataGrid Item Render in Flex 2.0
                isml Level 1
                Thanks for your advice.