Kendo Mobile & WebUI - Datagrid

3 posts, 0 answers
  1. Don
    Don avatar
    38 posts
    Member since:
    Oct 2006

    Posted 06 Jul 2012 Link to this post

    I have a datagrid inside a Kendo Mobile app.
    I am able to populate the grid with data on the initial page view but subsequent views continue to "add" to the datasource array dispite (all) my efforts to clear it prior to binding.

    I am using AJAX(obviously) and during my onSuccess callback, I clear the original source varable (array) ,
    then set it to the data returned from ajax and finally call my loadGrid routine to define the KendoGrid.
    I have even tried passing in the refreshed data array but I know it is still bound to the grid itself.

    I have also tried setting the grids datasource to null, and [] but it just keeps appending data and doesn't clear it.
    I can see my grids pager goping from 5 pages to 10.
    Is there a simple way to remove the data / binding?

    here is psuedo code:

    var CustData = [ ];

    function onSuccess(data,status)
    {
    CustomerData.length=0;
    CustomerData = [];
    CustomerData = data.d;
    loadgrid(CustomerData );    
    }

    function loadGrid(custData) {
      $("#grid").kendoGrid({ { data: [ ] }  }); // futile attempt to clear


        $("#grid").kendoGrid({
                  { data: custData, pageSize: 20 }
                   // dataSource: new kendo.data.DataSource({data: custData})
              });
    }
  2. Nikolay
    Nikolay avatar
    4 posts
    Member since:
    Apr 2010

    Posted 09 Jul 2012 Link to this post

    Hi Don,

    You can clear the grid with $("#grid").empty().
    But it would be better to just change the data, once you created the grid. Something like the following:

    var grid = $("#grid").data("kendoGrid");
    if (grid) {
        grid.dataSource.data(custData);
    } else {
        $("#grid").kendoGrid({ /*..*/ });


    For further assistance with kendo related issues, please use this forum: http://www.kendoui.com/forums.aspx


    Regards,
    Nikolay Tsenkov
  3. Don
    Don avatar
    38 posts
    Member since:
    Oct 2006

    Posted 09 Jul 2012 Link to this post

    Thank You Nikolay-
    I am not sure what I was doing wrong, but this works and allows me to continue forward.

    Thanks
Back to Top