gpt4 book ai didi

javascript - jsGrid 不会渲染 JSON 数据

转载 作者:行者123 更新时间:2023-12-03 05:28:51 29 4
gpt4 key购买 nike

我尝试在我的 MVC 项目中使用 jsGrid,因为客户端想要内联编辑和过滤。但是,我无法让它将 JSON 源加载到表中。我加载表格的 js 看起来像这样:

$("#jsGrid").jsGrid({
height: "50%",
width: "100%",

filtering: true,
inserting: true,
editing: true,
sorting: true,
paging: true,
autoload: true,

pageSize: 10,
pageButtonCount: 5,

deleteConfirm: "Do you really want to delete client?",

controller: {
loadData: function (filter) {
return $.ajax({
type: "GET",
url: "RICInstrumentCode/GetData",
data: filter,
dataType: "json"
});
},

insertItem: function (item) {
return $.ajax({
type: "CREATE",
url: "/api/RICInsrumentCodeTable",
data: item,
dataType: "json"
});
},

updateItem: function (item) {
return $.ajax({
type: "UPDATE",
url: "/api/RICInsrumentCodeTable/" + item.ID,
data: item,
dataType: "json"
});
},

deleteItem: $.noop

//deleteItem: function (item) {
// return $.ajax({
// type: "DELETE",
// url: "/api/data/" + item.ID,
// dataType: "json"
// });
//}
},

fields: [
{ name: "Code", type: "text", title: "RIC Instrument Code", width: 150 },
{ name: "Descr", type: "text", title:"RIC Instrument Code Description", width: 200 },
{ name: "RICInstrumentGroupId", type: "select", title: "RIC Instrument Group", items: countries, valueField: "Id", textField: "Name" },
{ name: "Active", type: "checkbox", title: "Is Active", sorting: true },
{ type: "control" }
]
});

});

loadData 是我一直在研究的内容。

从获取数据返回的 JSON 如下所示:

[{"Id":1,"Code":"test1","Descr":"first code test","RICInstrumentGroupId":2,"Active":true},{"Id":2,"Code":"APP","Descr":"Apples and bananas","RICInstrumentGroupId":4,"Active":true},{"Id":3,"Code":"1","Descr":"1","RICInstrumentGroupId":1,"Active":true},{"Id":4,"Code":"3","Descr":"3","RICInstrumentGroupId":3,"Active":false}]

到目前为止,我已经确认 ajax 正在触发,更改了我的数组标题以匹配调用的标题,并确保返回是有效的 JSON,我还能做什么?为什么这不起作用?

最佳答案

我本来就很傻,设置表格高度的位在没有高度的 div 中设置为 100%,这导致表格主体以 0px 的高度渲染,更改高度属性以自动修复它,因为数据一直都在那里.

谢谢你的建议!

关于javascript - jsGrid 不会渲染 JSON 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41039447/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com