JSGrid项目选择与数据库

时间:2018-09-18 17:44:00

标签: jsgrid

我的js-grid在json中有返回的url loadData URL,其中一些数据用于填充选择,正在填充选择,但应接收文本的列单元格为空

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}
]

返回:/app/Play/app/

[{"ID":"83","Country":"1","Temp":"6","Play 1":"3","Play 2":"2"]

我现在已经确认,通过点击表格行,该字段会显示选中的内容

1 个答案:

答案 0 :(得分:0)

我解决了

简而言之,在我返回的json /app/Play/app/上,这些项目都作为字符串,将它们转换为整数并可以工作。 返回:

..."Play 1": 3,"Play 2": 2]