1

I have the following kendo grid, after update I want my grid to be refreshed again, from datasource,but does not work with the following approach im not sure if imm putting the refresh datasource command in the right place,any help will be highly appreciated

 dataSource = new kendo.data.DataSource({
                        transport: {
                            read: function (options) {
                                options.success(result); // where data is the local data array
                            },
                            update: function (options) {

                                $.ajax({
                                    type: "POST",
                                    url: "/AdminTool/update_grid",
                                    data: options.data.models[0],
                                    dataType: "json",
                                    success: function (data) {
                                        options.success(data);
                                        // alert("success");
                                        $("#turbingrid").data("kendoGrid").dataSource.read();

                                    },
                                    error: function (data) {
                                        options.error(data);
                                        //  alert("error");
                                    },
                                });

                            },

                            parameterMap: function (options, operation) {
                                if (operation !== "read" && options.models) {
                                    return { models: kendo.stringify(options.models) };
                                }
                            }
                        },
                        batch:true,
                        pageSize: 40,
                        schema: {
                            //data: employee,
                            model: {
                                id: "DeviceIP",
                                fields: {
                                    DeviceIP: { editable: false, nullable: true },
                                    //Producer: { type:"string" },
                                    //3 Model: { type: "string" },
                                    DeviceType:{ type:"string" },
                                    Description:{ type:"string" },
                                    Username:{ type:"string" },
                                    Password:{ type:"string" },
                                    PublicIP: { type: "string" },
                                    ModelProducer: { type: "string" },
                                    TurbineId: {type:"string"}
                                    //UnitPrice: { type: "number", validation: { required: true, min: 1} },
                                    //Discontinued: { type: "boolean" },
                                    //UnitsInStock: { type: "number", validation: { min: 0, required: true } }
                                }
                            }
                        }


                    });
  • Is this line suposed to update the datatable? `$("#turbingrid").data("kendoGrid").dataSource.read();` – Daniel Aug 24 '17 at 11:39
  • @Daniel yes its –  Aug 24 '17 at 11:41
  • Depending on your version, [this might be useful](https://stackoverflow.com/questions/18399805/reloading-refreshing-kendo-grid), have you already tried it? – Daniel Aug 24 '17 at 11:58
  • @Daniel where should I put this code? –  Aug 24 '17 at 11:59
  • It depends, options.success is a `synchronous` or an `asynchronous` function? – Daniel Aug 24 '17 at 12:04
  • @Daniel I left it default,so I don't know by default which one it is,please give me a approach for either way,then ill try –  Aug 24 '17 at 12:09
  • I'm trying to find out in the documentation! Do you know the documentation link or something? – Daniel Aug 24 '17 at 12:10
  • options.success seems to be a `synchronous` call. Have you tried to use the `DataSource` instance reference you just created in the js? this: `var dataSource = new..`, instead of getting the instance via jQuery, couldn't you just use: `dataSource.read();`? – Daniel Aug 24 '17 at 12:24
  • I believe I already know what we're missing! – Daniel Aug 24 '17 at 12:50

1 Answers1

1

I used

$("#turbingrid").data("kendoGrid").dataSource.data(data);

instead of

$("#turbingrid").data("kendoGrid").dataSource.read();

to load the retrieved data to kendo Grid. Hope it helps.

oopsdazie
  • 716
  • 1
  • 7
  • 22