This is a migrated thread and some comments may be shown as answers.

Rebind and refresh dataSource on grid

4 Answers 2530 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
David Edwards
Top achievements
Rank 1
David Edwards asked on 29 Nov 2012, 03:39 PM
So I have a grid on a search page that I need to rebind on button click.

here is my code.

var sourceUrl = "Dynamic source url";

        var dataSource1 = new kendo.data.DataSource({
            type: "json",
            transport: {
                read: sourceUrl
            },
            serverOperation: false,
            serverSorting: true
        });

        var grid = $("#grid").data("kendoGrid");

        grid.dataSource = dataSource1;

        grid.dataSource.transport.read();
        grid.dataSource.read();

        grid.refresh(); 


This all happens on a button click event outside of the grid.  


The problem is, is that the grid is not actually refreshing.  The data is being pulled back successfully, but it is not getting displayed.
Since I have server sorting turned on on the grid, I clicked on one of the column headers and the data displayed properly.

What is server sorting doing to the grid to refresh it that is different than what I am doing?

4 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 30 Nov 2012, 08:16 AM
Hello David,

Assigning the DataSource instance to Grid widget's dataSource field is not supported and will not work as expected. It is preferable to assign the DataSource during the databound widget declaration, or in cases where changing the DataSource is required, you may use setDataSource method of the widget. This way the widget will be able to attached to DataSource's notification events and correctly refresh its state when needed.

Also note that calling read method of the DataSource is sufficient in order to repopulate the DataSource (which will automatically refresh the widget's content).

Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
David Edwards
Top achievements
Rank 1
answered on 03 Dec 2012, 02:46 PM
perfect.  Thanks for your help.  I had not seen the setDataSource() method.  
0
Trushar
Top achievements
Rank 1
Veteran
answered on 09 Dec 2016, 03:11 PM
Hi I have similar issue but in my case filter is not getting refresh when result is changing in grid. can you put some light on this?
0
Rosen
Telerik team
answered on 09 Dec 2016, 03:20 PM

Hello Trushar,

I'm afraid that I'm not able to tell what may caused such behavior judging from the provided information. 

Due to the age of this thread I will ask you to open a separate support request in which to provide as much information about your scenario and the behavior you are facing as possible. Code snippets, a runnable test page demonstrating the issue will be welcomed. 

Regards,
Rosen
Telerik by Progress
Kendo UI is ready for Visual Studio 2017 RC! Learn more.
Tags
Grid
Asked by
David Edwards
Top achievements
Rank 1
Answers by
Rosen
Telerik team
David Edwards
Top achievements
Rank 1
Trushar
Top achievements
Rank 1
Veteran
Share this question
or