我有这些数据库列,但我希望它们位于一列中。我该怎么做呢?我想是用 mRender 吧?
/* Address */
{"sTitle": "Address",
"bVisible": true,
"bSearchable": true},
/* City */
{"sTitle": "City",
"bVisible": true,
"bSearchable": true},
/* State */
{"sTitle": "State",
"bVisible": true,
"bSearchable": true},
/* Zip */
{"sTitle": "Zip",
"bVisible": true,
"bSearchable": true},
最佳答案
假设数据表 get 返回的列是地址、城市、州、邮政编码 1-4
如果返回的数据是常规数组
{ "mData": 0 , //or address field
"mRender" : function ( data, type, full ) {
//data = mData
//full is the full array address= [0] city = [1] state=[2] zip=[3]
return data+', '+full[1]+', '+full[2]+', '+full[3];}
},
如果您的数据是关联数组
{ "mData": 'address' ,
"mRender" : function ( data, type, full ) {
return data+', '+full['city']+', '+full['state']+', '+full['zip'];}
},
或者你可以独立于mData调用mRender(尽管这种情况似乎不需要)
{ "mData": null ,
"mRender" : function ( data, type, full ) {
return full['address']+', '+full['city']+', '+full['state']+', '+full['zip'];}
},
编辑:对于数据表 1.10,只需稍微更改名称,删除“m”
{ "data": null ,
"render" : function ( data, type, full ) {
return full['address']+', '+full['city']+', '+full['state']+', '+full['zip'];}
},
*注意,我没有考虑您是否应该将此数据存储在一列中,只是显示其完成方式
关于merge - 数据表 - 将列合并在一起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19777075/