开发者

how to concate two datafield in a datagridcolumn?

开发者 https://www.devze.com 2023-02-27 11:06 出处:网络
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 labe

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

精彩评论

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