Author Topic: Default Sorting is not working as expected.  (Read 4121 times)

Ajay

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 31
    • View Profile
Default Sorting is not working as expected.
« on: June 16, 2015, 07:54:33 pm »
Hi,
I am using evaluation copy of PQGrid.
 
As per documentation,sorting is enabled by default in both Api documentation and Demos.

When i tried to do the same,sorting is not happening until i add the below line of code.

 searchLicenseUsageGrid.pqGrid("option", "dataModel", { data: data, sorting: 'local', sortIndx: 'name' });

Is it necessary to add every time in all the pq grids of the application?
Is there any alternative so that we can achieve with out adding the above line in all the pages?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6126
    • View Profile
Re: Default Sorting is not working as expected.
« Reply #1 on: June 19, 2015, 03:53:28 pm »
Sorting is enabled by default and default value of dataModel.sorting is "local".

It seems from your code that you have assigned data to grid in a manner which has overwritten default values of dataModel.

pqGrid("option", "dataModel", { data: data }); // this would overwrite the whole dataModel with  { data: data} and other properties including dataModel.sorting become undefined.

Correct way to assign data without overwriting other properties.

pqGrid("option", "dataModel.data", data }); // this would not change other properties of dataModel.
« Last Edit: June 19, 2015, 03:57:00 pm by paramquery »

Ajay

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Default Sorting is not working as expected.
« Reply #2 on: June 22, 2015, 04:18:38 pm »
Thanks it got worked.