简体   繁体   English

项目渲染器-在flex中渲染一行

[英]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). 我在不同的列上应用了两个不同的渲染器(在第1列说Renderer A,在第3列说Renderer B)。

Now in set Data() of B (column three's renderer) I am changing a Requiredflag on the basis of some condition. 现在,在B(第三个列的渲染器)的set Data()中,我将根据某些条件更改Requiredflag。 In set Data of A (Column 1's renderer), I am checking the RequiredFlag and changing its style accordingly. 在A的设置数据(列1的渲染器)中,我正在检查RequiredFlag并相应地更改其样式。

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). 问题是对于行,因为A是第一列,所以A在B之前渲染,因此它没有获得requiredFlag的更新值(因为requiredFlag在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. 或者如果我可以在第三列的单元格中requiredFlag的值更改后再次渲染整个行。

See the itemrender as a view, so the renderer itself does not do any computation, just check the value of the object... 将itemrender视为视图,因此渲染器本身不进行任何计算,只需检查对象的值即可。

If I understood correctly I'll do something like that... 如果我理解正确,我会做类似的事情...

(maybe you need to move the check from set data to updatedisplaylist) (也许您需要将支票从设置数据移动到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 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 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... 如果这不是您想要的,请添加一些代码...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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