easyui datagrid columns 如何取得json 內嵌對象(many-to-one POJO class)

來源:互聯網
上載者:User

標籤:style   blog   http   color   io   ar   for   資料   div   

http://www.iteye.com/problems/44119

http://hi.baidu.com/lapson_85/item/7733586e60b08500a1cf0f8d

————————————————————————————————————————————————————————————————————————————————————————

1. json的資料格式:

      var map = {"uname":‘‘,"upwd":‘‘,"role":{“rolename”:‘‘,"roleLevel":‘‘}}

把這個json格式綁定到datagrid的filed屬性上:

columns : [ [ 
{
 field : uname,
 title : uname,
width : 200,
rowspan : 2,
align : ‘center‘
},{
 field : upwd,
 title : upwd,
width : 80,
rowspan : 2,
align : ‘center‘
}, {
 field :‘ role.rolename’ ,
 title : ‘角色名稱‘,
width : 100,
rowspan : 2,
align : ‘center‘
}, {
 field : ‘role . roleLevel’ ,
 title : ‘等級‘,
width : 80,
rowspan : 2,
value : 1,
align : ‘center‘
 }]]

 

jquery easyui 是不支援嵌套對象的資料轉化的。。比如:(role.roleLevel)

我們必須修改原始碼:

我的用的是appendRow 和updateRow 2個方法。所以修改這2個方法的賦值地方

如果用到appendRow:

//cc.push(_571[_573]); --原始碼    7062行

改為:
cc.push(eval("_571[‘"+_573.replace(/\./g,"‘][‘")+"‘]"));

 

如果用到updateRow :

//cell.html(rows[_57a][_57b]); -- 原始碼   7638行

改為:
cell.html(eval("rows[_57a][‘"+_57b.replace(/\./g,"‘][‘")+"‘]"));

 

注意:我的jquery easyui 的版本為1.2.6的版本

 

請加qq群:100969361

 

——————————————————————

    {field:‘productType‘,title:‘產品類別‘,width:160,formatter:function(value,rowData,rowIndex){          //可以試試這個對不對          //return value.prodType;          return rowData.productType.prodType;      }},    

 

easyui datagrid columns 如何取得json 內嵌對象(many-to-one POJO class)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.