带有数据库的 JSGrid 项目 Select
JSGrid Item Select with DB
我的 js-grid 在 json 中有 url loadData 和 return,其中一些数据用于填充 selects,select正在填充 s,但应接收文本的列单元格为空
controller: {
loadData: function (filter) {
var data = $.Deferred();
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
url: "/app/Play/app/",
dataType: "json"
}).done(function(response){
data.resolve(response);
});
return data.promise();
},
}
fields: [
{ name: "ID", type: "text" },
{ name: "Country", type: "text"},
{ name: "Play 1", type: "select", items: db.players, valueField: "Id",textField: "Name" },
{ name: "Play 2", type: "select", items: db.players, valueField: "Id", valueField: "Id",textField: "Name" }
]
db.players= [
{ Name: "Name 1", Id: 1},{ Name: "Name 2", Id: 2},{ Name: "Name 3", Id: 3}
]
Return: /app/Play/app/
[{"ID":"83","Country":"1","Temp":"6","Play 1":"3","Play 2":"2"]
我现在已经通过单击 table 行验证了该字段显示 select selected
我解决了
简单地说,在我的 return json /app/Play/app/
上,项目是字符串,将它们转换为整数并工作。
Return:
..."Play 1": 3,"Play 2": 2]
我的 js-grid 在 json 中有 url loadData 和 return,其中一些数据用于填充 selects,select正在填充 s,但应接收文本的列单元格为空
controller: {
loadData: function (filter) {
var data = $.Deferred();
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
url: "/app/Play/app/",
dataType: "json"
}).done(function(response){
data.resolve(response);
});
return data.promise();
},
}
fields: [
{ name: "ID", type: "text" },
{ name: "Country", type: "text"},
{ name: "Play 1", type: "select", items: db.players, valueField: "Id",textField: "Name" },
{ name: "Play 2", type: "select", items: db.players, valueField: "Id", valueField: "Id",textField: "Name" }
]
db.players= [
{ Name: "Name 1", Id: 1},{ Name: "Name 2", Id: 2},{ Name: "Name 3", Id: 3}
]
Return: /app/Play/app/
[{"ID":"83","Country":"1","Temp":"6","Play 1":"3","Play 2":"2"]
我现在已经通过单击 table 行验证了该字段显示 select selected
我解决了
简单地说,在我的 return json /app/Play/app/
上,项目是字符串,将它们转换为整数并工作。
Return:
..."Play 1": 3,"Play 2": 2]