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

Compare Old and New Values After Grid Refresh

2 Answers 376 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 02 Feb 2012, 08:39 PM
I have a Grid instance that is being refreshed every X seconds and would like to compare the new data (remote) with the existing data, which then affect how the data is displayed within the grid.  I have looked through the documentation and the forums but can't seem to find a way to compare the two.  The "change" config seems to be for only inline editing... but maybe I am wrong.  Any help/links would be appreciated.  Here is an example of what is going on here (I would like to compare the values returned for "rate" and "high_rate"):

// KendoUI grid
var kgrid = $("#rate_grid").kendoGrid({
  dataSource: {
    data: get_rates(),
    pageSize: 100
  },
  height: 360,
  groupable: false,
  scrollable: {
    virtual: true
  },
  sortable: true,
  pageable: false,
  columns: [ {
    field: "rate_name",
    width: '65px',
    title: "Name"
  } , {
    field: "rate",
    title: "Rate"
  } , {
    field: "high_rate",
    title: "High"
  }],
  rowTemplate: kendo.template($("#rowTemplate").html()),
  dataBound: onDataBound
});
 
setInterval( function() {
  // if KendoUI grid instance, update it
  if (typeof kgrid !== "undefined")
  {
    $('#rates_load small').text();
    var re_grid = $("#rate_grid").data("kendoGrid");
    var new_grid_data = get_rates();
    re_grid.dataSource.data(new_grid_data);
    re_grid.refresh();         
  }
}, 5000);

2 Answers, 1 is accepted

Sort by
0
Vivek
Top achievements
Rank 1
answered on 03 Feb 2012, 12:49 AM
Have you tried using a separate dataSource and then using the data() event? You can then query the dataSource, grab the old data and then refresh and compare results.
0
Matt
Top achievements
Rank 1
answered on 03 Feb 2012, 04:30 PM
@Vivek, thanks for the idea.  I feel like I'm not utilizing the inherit power of the DOM and Kendo's Grid this way but it's worth giving a shot.  I'm using the datasource: data: function() to update a "current" javascript global variable and the "new" javascript global variable, then have the dataBound callback compare them and dynamically modify the GUI as needed.  I feel like this is a bit of a round-about approach, but I'll let you know how it goes. 
Tags
Grid
Asked by
Matt
Top achievements
Rank 1
Answers by
Vivek
Top achievements
Rank 1
Matt
Top achievements
Rank 1
Share this question
or