Refresh Kendo UI grid data by reading a variable

21,855

If jsvar contains an array, the Kendo data source will create a model for each array item, so if you modify the original array, it won't change the DataSource. If you want to change the data, you should do it like this:

grid.dataSource.data(jsvar);
Share:
21,855
XIMRX
Author by

XIMRX

I am senior web developer at Hearty Tools, you can hire me for any kind of small or big web related job, my passion is website design and development; I have been working on PHP, Node, jQuery and other web technologies. If your are interested in website development services you can contact me. I'm available to work as Freelancer.

Updated on December 26, 2020

Comments

  • XIMRX
    XIMRX over 3 years

    Grid reads data from a javascript variable.

        $("#grid").kendoGrid({
        dataSource: {
            type: "text",
            data: jsvar,
            schema: {
                model: {
                    fields: {
                        id: {type: "string", editable: false},
                        name: {type: "string"}
                    }
                }
            },
            pageSize: 20
        },
        pageable: {
            input: true,
            numeric: true
        },
       //toolbar: [{text: "Add"}],
        columns: [
            {command: [{text: "Edit", click: showDetailse}, {text: "View", click: viewoneitm}], title: " ", width: "170px"},
    
    
        ]
    });
    

    Then I change value of this variable jsvar with ajax and wait for ajax response and after that when I refresh grid with

                jQuery("#grid").data("kendoGrid").dataSource.read();
                jQuery("#grid").data("kendoGrid").refresh();
    

    The grid is not repopulated with new data and old data stays in grid. Please tell me how to refresh grid data. This worked fine and grid used to refresh perfectly untill I proviced static data, but after I used ajax and then 'refresh' it failed to update