bootstrapTable绑定不出数据,ajax返回的数据如下:

2024-12-25 01:50:41
推荐回答(1个)
回答1:

你返回的json数据应该是:rows:[{},{}]
$(function () {
var oTable = new TableInit();
oTable.Init();
});
var TableInit = function () {
var oTableInit = new Object();
oTableInit.queryUrl = '/Official/GetSearchFileList' + '?rnd=' +Math.random();
//初始化Table
oTableInit.Init = function () {
$('#table-javascript').bootstrapTable({
method: 'get',
url: oTableInit.queryUrl,
height: $(window).height() - 290,
striped: true,
pagination: true,
singleSelect: false,
pageSize: 2,
pageNumber: 1,
pageList: [10, 50, 100, 200, 500],
search: false, //不显示 搜索框
showColumns: false, //不显示下拉框(选择显示的列)
sidePagination: "server", //服务端请求
queryParams: oTableInit.queryParams,
minimunCountColumns: 2,
queryParamsType: "",//分页参数设置
formatNoMatches: function () {
return '未检索到**信息';
},
columns: [
{
field: 'BH',
title: '序号',
width: 20,
align: 'center',
valign: 'middle',
sortable: false,
}, {
field: 'TITLE',
title: '**名称',
width: 200,
align: 'left',
valign: 'top',
sortable: false,
}, {
field: 'Creater',
title: '创建人',
width: 50,
align: 'left',
valign: 'top',
sortable: false
}, {
field: 'CreateTime',
title: '创建时间',
width: 110,
align: 'middle',
valign: 'top',
sortable: false
}, {
field: 'operate',
title: '操作',
width: 100,
align: 'center',
valign: 'middle',
formatter: operateFormatter,
events: operateEvents
}],
onLoadSuccess: function () {
//layer.msg('加载成功');
},
onLoadError: function () {
layer.msg('未检索到**信息');
}
});
};
//销毁表格
oTableInit.Destory = function () {
$('#table-javascript').bootstrapTable('destroy');
};
//得到查询的参数
oTableInit.queryParams = function (params) {
var temp = {
pageSize: params.pageSize,
pageIndex: params.pageNumber,
Title:$("#Title").val(),
startDate: $("#startDate").val(),
endDate: $("#endDate").val()
};
return temp;
};
return oTableInit;
};
function operateFormatter(value, row, index) {
return '查看';
}
window.operateEvents = {
'click .detail': function (e, value, row, index) {
var url = '@Url.Content("~/**/**?id=")' + row.ID;
window.open(url, '_blank');
}
};