datables处理带"."的数据做了一些特殊处理
前端JavaScript
columns: [
{data: "creator.name",title: "创建者", defaultContent: "", width: 120,align: "left"},
{data: "creator.email",title: "创建者邮箱", defaultContent: "", width: 120, align: "left"},
{data: "creator.mobilePhoneNumber",title: "创建者手机", defaultContent: "", width: 120, align: "left"}
]
后台返回的数据格式必须为:
creator:{name: "张三", email: "zhangsan@xx.com", mobilePhonoeNumber: "1333333333"}
datatables的源码在1274行,代码为
//else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
// mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
//{
// /* If there is a . in the source string then the data source is in a
// * nested object so we loop over the data for each level to get the next
// * level down. On each loop we test for undefined, and if found immediately
// * return. This allows entire objects to be missing and sDefaultContent to
// * be used if defined, rather than throwing an error
// */
// var fetchData = function (data, type, src) {
// var arrayNotation, funcNotation, out, innerSrc;
//
// if ( src !== "" )
// {
// var a = _fnSplitObjNotation( src );
//
// for ( var i=0, iLen=a.length ; i<iLen ; i++ )
// {
// // Check if we are dealing with special notation
// arrayNotation = a[i].match(__reArray);
// funcNotation = a[i].match(__reFn);
//
// if ( arrayNotation )
// {
// // Array notation
// a[i] = a[i].replace(__reArray, '');
//
// // Condition allows simply [] to be passed in
// if ( a[i] !== "" ) {
// data = data[ a[i] ];
// }
// out = [];
//
// // Get the remainder of the nested object to get
// a.splice( 0, i+1 );
// innerSrc = a.join('.');
//
// // Traverse each entry in the array getting the properties requested
// if ( $.isArray( data ) ) {
// for ( var j=0, jLen=data.length ; j<jLen ; j++ ) {
// out.push( fetchData( data[j], type, innerSrc ) );
// }
// }
//
// // If a string is given in between the array notation indicators, that
// // is used to join the strings together, otherwise an array is returned
// var join = arrayNotation[0].substring(1, arrayNotation[0].length-1);
// data = (join==="") ? out : out.join(join);
//
// // The inner call to fetchData has already traversed through the remainder
// // of the source requested, so we exit from the loop
// break;
// }
// else if ( funcNotation )
// {
// // Function call
// a[i] = a[i].replace(__reFn, '');
// data = data[ a[i] ]();
// continue;
// }
//
// if ( data === null || data[ a[i] ] === undefined )
// {
// return undefined;
// }
// data = data[ a[i] ];
// }
// }
//
// return data;
// };
//
// return function (data, type) { // row and meta also passed, but not used
// return fetchData( data, type, mSource );
// };
//}
我的解决方案
返回的数据格式为:
{creator.name: "张三", creator.email: "zhangsan@xx.com", creator.mobilePhonoeNumber: "1333333333"}
需要把dataTables的代码注释掉才能展示数据
分享到:
相关推荐
使用datatables获取后台响应数据时,只能获取到aaData,而其他数据无法显示问题
适合前端初学者 jquery中的datatable使用ajax读取数据 并展示表格数据
datatables 插件
Datatables实现多选框与AJAX返回数据 JAVA版
Laravel开发-datatables Laravel4的数据表jquery插件的服务器端处理程序
Datatables是一款jquery表格插件。它是一个高度灵活的工具,可以将任何HTML表格...这篇文章主要介绍了DataTables+BootStrap组合使用Ajax来获取数据并且动态加载dom的方法(排序,过滤,分页等),需要的朋友可以参考下
开发工具 jquery.dataTables.min开发工具 jquery.dataTables.min开发工具 jquery.dataTables.min开发工具 jquery.dataTables.min开发工具 jquery.dataTables.min开发工具 jquery.dataTables.min开发工具 jquery....
datatables 异步请求数据
开发工具 dataTables.bootstrap.min开发工具 dataTables.bootstrap.min开发工具 dataTables.bootstrap.min开发工具 dataTables.bootstrap.min开发工具 dataTables.bootstrap.min开发工具 dataTables.bootstrap.min...
DataTables提供了多种用户设置,自动分页、排序(包括多条件排序)、隐藏部分列等功能。
jquery.datatables,异步请求后台数据时,调用api动态合并行。
用datatables和bootstrap做的一个表格的demo
解决datatables出现FixedHeader 2 is not supported with DataTables' scrolling mode at this time的问题
用于dataTables 使用dataTables添加行辅助按钮如 修改/删除.
ssm整合datatables实例Demo,springMVC spring mybatis datatables
几乎支持任何数据源:DOM, javascript, Ajax 和 服务器处理 支持不同主题 DataTables, jQuery UI, Bootstrap, Foundation 各式各样的扩展: Editor, TableTools, FixedColumns …… 丰富多样的option和强大的...
jquery datatables前后台数据交互分页实例。