开发者

how to concate two datafield in a datagridcolumn?

ho开发者_StackOverflow中文版w to concate two datafield in a datagridcolumn?


I suppose that your question is to show two data fields from the data provider as data for a dataGridColumn.

You can use labelFunction for the dataGridColumn.

Here is a sample.

    [Bindable]private var myDataProvider:ArrayCollection = new ArrayCollection([
                            {fname: 'fname 1', lname: 'lname 1'},
                            {fname: 'fname 2', lname: 'lname 2'},
                            {fname: 'fname 3', lname: 'lname 3'}
                        ]);

    private function myLabelFunction(item:Object, column:DataGridColumn):String {
        return  item.fname + ' ' + item.lname;
    }

    <mx:DataGrid dataProvider="{myDataProvider}">
        <mx:columns>
            <mx:DataGridColumn labelFunction="{myLabelFunction}" headerText="Full Name" />
        </mx:columns>
    </mx:DataGrid>


use labelFunction for the dataGridColumn.[

private function concat(item:Object, column:DataGridColumn):String
        {
            return (item.id+""+item.catCode);

//use this in datagrid

if use dataprovider as arraycollection you can declare as

[Bindable]private var cat:ArrayCollection = new ArrayCollection();   

i hope this is enough when you get data from users by entering in textfields... using form....:-)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜