开发者

Flex Datagrid and finding number member variable of a class

i have two que开发者_如何学JAVAstions

  1. How to populate a flex datagrid from an Arraycollection without specifying DataGridColumn's individually. Is there any custom datagrid available where I can pass the datasource arraycollection and see the data populated in the output.

  2. Without knowing the structure / bluprint of an object is there anyway to find how many member variable that class have?


With respect to your second question - there are 2 ways to accomplish this:

  1. Using a for..in loop. This only works for dynamically added properties.
  2. Using the describeType API. This will return a rich XML object describing an object, including all of its member variables as well as their visibility.

You can read more about these two techniques here.


       static public function getDetails(argData:Object , grid:DataGrid):void { 
            // Get the Button control's E4X XML object description.
            var classInfo:XML = describeType(argData);
            // List accessors as properties.
            var _columnList:Array = new Array();
            for each (var a:XML in classInfo..accessor) {
                // Do not get the property value if it is write only.
                var _column:DataGridColumn = new DataGridColumn;  
                // Setting properties  
                _column.headerText = a.@name;  
                _column.dataField = a.@name;  
                _column.width = 180;  
                _columnList.push(_column);   
            } 
            grid.columns = _columnList;
        }

Populated Datagrid through this routine , helps a lot debugging my result data.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜