EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: zh_CN on March 26, 2014, 11:47:43 PM



Title: 大家好:About 【datagrid formatter funtion】 does't return the right value
Post by: zh_CN on March 26, 2014, 11:47:43 PM
Code:
...
        $grid.datagrid({
        fit: true,
        border: false,
        /*url: '',
        method:'get',*/
        data:{$list},
        pagination: true,
        columns: [[
                {checkbox: true},
                {field: 'id', title: 'ID', width: 20, align: 'center'},
                {field: 'title', title: '标题', width: 250, align: 'center'},
                {field: 'name', title: '标识', width: 150, align: 'center'},
                {field: 'create_time', title: '创建时间', width: 100, align: 'center', sortable: true},
                {field: 'update_time', title: '更新时间', width: 100, align: 'center', sortable: true},
                {field: 'id', title: '操作', width: 300, align: 'center',
                    formatter: function(value,row,index) {
                        //return '<span title="编辑" class="img-btn icon-edit" kid=' + value + '></span>';
                        return '<font color="red">aa</font>';
                    }
                }
            ]],
        toolbar: [{
                text: '新增',
                iconCls: 'icon-add',
                handler: context.addView
            }, {
                text: '删除',
                iconCls: 'icon-remove',
                handler: context.doDelete
            }],
        onLoadSuccess: function() {
            $.parser.parse();
        }
           
    });
...

I't return the field value, Is not the result I want.



The right return value is <font color="red">aa</font>


Title: Re: 大家好:About 【datagrid formatter funtion】 does't return the right value
Post by: zh_CN on March 27, 2014, 05:35:47 AM
And the documentation write:
Code:
$('#dg').datagrid({
columns:[[
{field:'userId',title:'User', width:80,
formatter: function(value,row,index){
if (row.user){
return row.user.name;
} else {
return value;
}
}
}
]]
});

So, I find no any error about the syntax!


Title: Re: 大家好:About 【datagrid formatter funtion】 does't return the right value
Post by: stworthy on March 27, 2014, 06:44:08 AM
Please refer to this tutorial http://www.jeasyui.com/tutorial/datagrid/datagrid7.php.


Title: Re: 大家好:About 【datagrid formatter funtion】 does't return the right value
Post by: zh_CN on March 27, 2014, 06:57:22 AM
Please refer to this tutorial http://www.jeasyui.com/tutorial/datagrid/datagrid7.php.


I use id field twice, when I del one, I't ok.
(同一个字段我用了2次,我去掉其中一个就可以了)

  columns: [[
                {checkbox: true},
delete this "id"        {field: 'id', title: 'ID', width: 20, align: 'center'},
                {field: 'title', title: '标题', width: 250, align: 'center'},
                {field: 'name', title: '标识', width: 150, align: 'center'},
                {field: 'create_time', title: '创建时间', width: 100, align: 'center', sortable: true},
                {field: 'update_time', title: '更新时间', width: 100, align: 'center', sortable: true},
or delete this id       {field: 'id', title: '操作', width: 300, align: 'center',
                    formatter: function(value,row,index) {
                        //return '<span title="编辑" class="img-btn icon-edit" kid=' + value + '></span>';
                        return '<font color="red">编辑</font>';
                    }

And now how can use id field twice in one datagrid( ther first field and the last field)?
(我如何在第一个和最后一个字段都使用 id 这个 field呢?)