Rebind and refresh dataSource on grid

3 posts, 0 answers
  1. David Edwards
    David Edwards avatar
    6 posts
    Member since:
    Aug 2009

    Posted 29 Nov 2012 Link to this post

    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{
                type: "json",
                transport: {
                    read: sourceUrl
                serverOperation: false,
                serverSorting: true

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

            grid.dataSource = dataSource1;



    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?
  2. Rosen
    Rosen avatar
    3214 posts

    Posted 30 Nov 2012 Link to this post

    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).

    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. David Edwards
    David Edwards avatar
    6 posts
    Member since:
    Aug 2009

    Posted 03 Dec 2012 Link to this post

    perfect.  Thanks for your help.  I had not seen the setDataSource() method.  
Back to Top