EasyUI Forum
September 14, 2025, 04:07:41 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: 大家好:About 【datagrid formatter funtion】 does't return the right value  (Read 17366 times)
zh_CN
Newbie
*
Posts: 32



View Profile Email
« 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>
Logged

From the great China
zh_CN
Newbie
*
Posts: 32



View Profile Email
« Reply #1 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!
Logged

From the great China
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #2 on: March 27, 2014, 06:44:08 AM »

Please refer to this tutorial http://www.jeasyui.com/tutorial/datagrid/datagrid7.php.
Logged
zh_CN
Newbie
*
Posts: 32



View Profile Email
« Reply #3 on: March 27, 2014, 06:57:22 AM »



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呢?)
« Last Edit: March 27, 2014, 07:40:46 AM by zh_CN » Logged

From the great China
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!