问题描述
我有一个 jsGrid,我想在其中显示具有多个外键的数据库表中的数据,因此网格数据的某些字段是引用不同来源的外键:为此,我编写了以下内容
$(function() {
$.when(
$.ajax({type: "GET",url: "/datasource1/"}),$.ajax({type: "GET",url: "/datasource2/"})
).then(
(data1,data2) => {
$("#jsGrid").jsGrid({
// irrelevant options for the grid
controller: {
loadData: function(filter) {
return $.ajax({
type: "GET",url: "/griddata/",data: filter
});
},insertItem: function(item) {...},updateItem: function(item) {...},deleteItem: function(item) {...}
},fields: [
{ name: "foreign1",title: "FK1",type: "select",width: 100,items: data1,valueField: "id",textField: "value" },{ name: "foreign2",title: "FK2",items: data2,{ type: "control" }
]
});
});
});
据我所知,when
应该等待两个 ajax 调用来检索它们的数据,然后呈现网格。不幸的是,我可以看到网格中的行,但没有这些字段的值,无论是外键还是 data1
或 data2
数组上的相应值(两者都被正确检索)。>
我错过了什么吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)