JSGrid Item Select with DB

1.8k Views Asked by At

My js-grid has the url loadData with return in json, some of this data is for populating selects, the selects are being filled, but the column cell that should receive the text is blank

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

I have now verified that by clicking on the table row, the field appears with the select selected

1

There are 1 best solutions below

0
On BEST ANSWER

I solved

Simply, on my return json /app/Play/app/, the items were as string, converted them to integers and worked. Return:

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