Author Topic: dataModel.data setter not working if data is empty  (Read 2229 times)

EPM Solutions

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 182
    • View Profile
dataModel.data setter not working if data is empty
« on: December 28, 2017, 03:29:39 pm »
Hello Team,

We are  passing data to dataModel.data dynamically and sometime the data is empty and in this situation it gives error and the grid is not working properly.
On Load if we pass empty data it is working fine but when i apply custom filter on the grid and if there is no data in the array it gives error.

Please check the below code.
      var exData = [];
      $("#grid_Executing").pqGrid("option", "dataModel.data", exData);
      $("#grid_Executing").pqGrid('refreshView');


For reference i created one JsFiddle please check the below URL and for produce the error please click on the Empty Data button and see error in console.

JSFiddle URL : http://jsfiddle.net/h4rmbx70/26/

Please check above URL and give your suggestion on this.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: dataModel.data setter not working if data is empty
« Reply #1 on: December 28, 2017, 03:55:30 pm »
When there is no data it should be [] instead of null or undefined.

And call refreshDataAndView instead of refreshView.


$("#grid_array").pqGrid("option", "dataModel.data", empty_data || []);
$("#grid_array").pqGrid('refreshDataAndView');

EPM Solutions

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 182
    • View Profile
Re: dataModel.data setter not working if data is empty
« Reply #2 on: December 29, 2017, 07:57:49 am »
Thanks... :)

It's working fine  8) ;D :D ;) :)