简体   繁体   中英

Item renderer - Rendering a row in flex

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.

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM