0
votes

I have got a datagrid with three columns. I have applied two different renderers on different columns (Say Renderer A at column 1 and Renderer B at column 3).

Now in set Data() of B (column three's renderer) I am changing a Requiredflag on the basis of some condition. In set Data of A (Column 1's renderer), I am checking the RequiredFlag and changing its style accordingly.

The problem is for a Row, A renders before B as it is the first column, so it does not get the updated value of requiredFlag (as the requiredFlag is updated in B).

So can I somehow render the first column's cell again after rendering third column's cell? Or if I can render the whole row again after the value of requiredFlag changes in third column's cell.

1
Because of this, my first column's cell's style doesn't comes in sync with the third columns's requiredFlag value :( - Nirjhar Dave
Ok a rule of thumb to follow let the renderers do the rendering not data manipulation. Think of a renderer as a view. So with that in mind do the update to the data provider before you update the datagrid. - The_asMan
do you mean renderer B will change the dataProvider?refresh dataprovider will be ok. So "requiredFlag" or "style" should be part of dataProvider, then they can be updated when datasource changed. - simmone

1 Answers

0
votes

See the itemrender as a view, so the renderer itself does not do any computation, just check the value of the object...

If I understood correctly I'll do something like that...

(maybe you need to move the check from set data to updatedisplaylist)

example:

class Test
{

   public var col1:String = "Everything";
   public var col3:String = "Cars";

   public function get color():uint
   {
     if (col1 == "Everything")
       return 0xff0000;

     return 0x000000;
   }

}

itemrendererA.mxml

override public function set data(value:Object):void
{
   super.data = value;
   if (super.data != null && super.data is Test)
   {
      // do what you need to do..
      lbl1.text = (super.data as Test).col1;
      lbl1.setStyle("color", (super.data as Test).color);
   }
}

itemrendererB.mxml

override public function set data(value:Object):void
{
   super.data = value;
   if (super.data != null && super.data is Test)
   {

      if ( (super.data as Test).color == 0xff0000)
         // do something
      else
        // do something else
   }
}

if that's not what you're looking for, please add some of your code...