最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

数据表

运维笔记admin19浏览0评论

数据表

数据表

本文介绍了数据表 - 将列合并在一起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有这些数据库列,但我希望它们位于一列中.我该怎么做?使用 mRender,我想?

I have these database columns, but I want them to be in one column. How would I do that? With mRender, I think?

/* 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},

推荐答案

前提是datatables get返回的列是address, city, state, zip 1-4

provided that the columns returned by the datatables get are address, city , state, zip 1-4

如果你返回的数据是一个普通数组

if your data returned is a regular array

{ "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];} },

如果您的数据是关联数组

if your data is an associate array

{ "mData": 'address' , "mRender" : function ( data, type, full ) { return data+', '+full['city']+', '+full['state']+', '+full['zip'];} },

或者您可以独立于 mData 调用 mRender(尽管在这种情况下似乎不需要)

or you can call mRender independent of mData (though it seems not needed for this situation)

{ "mData": null , "mRender" : function ( data, type, full ) { return full['address']+', '+full['city']+', '+full['state']+', '+full['zip'];} },

对于数据表 1.10,只需稍微更改名称,去掉m"

for datatables 1.10, just change the names a bit, drop the "m"

{ "data": null , "render" : function ( data, type, full ) { return full['address']+', '+full['city']+', '+full['state']+', '+full['zip'];} },

*注意我没有考虑您是否应该将这些数据存储在一列中,只是显示它是如何完成的

*note i'm not taking into account whether you should store this data in one column, just showing how its done

数据表

发布评论

评论列表(0)

  1. 暂无评论