开发者

ADVANCED DATA GRID: Setting properites of individual columns in grid mxml tag

开发者 https://www.devze.com 2022-12-21 14:09 出处:网络
Is it possible to control the properties of \'advancedgridcolumns\' in \'advanc开发者_StackOverflow社区eddatagrid\' mxml tag. For e.g. suppose the grid data provider has 3 different fields. Out of the

Is it possible to control the properties of 'advancedgridcolumns' in 'advanc开发者_StackOverflow社区eddatagrid' mxml tag. For e.g. suppose the grid data provider has 3 different fields. Out of these 3 fields, one field is 'to_be_decided'. This field should not be displayed initially. Only the remaining 2 columns should be displayed (visible true) and the third column (one with data field as 'to_be_decided', visible flag will be false here ) should be hidden. It will be visible when some event like a button click or something is fired.

We can do this in action script coding by accessing individual columns of grid and taking appropriate actions. But will it be possible to do so in mxml? Is there some default property in grid that can be used here ?

In mxml I can not access them individually in the grid (under tag) and hence I can not set the visible attributes individually for each of them. To add them one by one in 'columns' tags I would be required to know the data field in array collection and that I dont know. Only data field known is 'to_be_decided', rest two fields will vary time to time. Therefore even if I addd this one gridcolumn in 'columns' tag what about the other two?

Something like this :

 <mx:columns>
      <mx:AdvancedDataGridColumns dataField='to_be_decided' visible=false>
      <!-- How to add other 2 columns here ? -->
 </mx:columns>

Any suggestions/ideas in this regard?

If I failed to make myself clear please let me know I will try to reframe my question. Thanks in advance.


You could try

 <mx:columns>
    <mx:Repeater id="rp" dataProvider="{yourArrayCollection}">
      <mx:AdvancedDataGridColumns dataField="{rp.currentItem.fieldName}" visible="{rp.currentItem.show}">
    </mx:Repeater>
 </mx:columns>

where your dataProvider (yourArrayCollection) is an ArrayCollection of objects with properties "fieldName" (String) and "show" (Boolean).

0

精彩评论

暂无评论...
验证码 换一张
取 消