ParamQuery grid support forum

General Category => ParamQuery Pro Evaluation Support => Topic started by: rickpqu on August 12, 2015, 07:06:35 pm

Title: Sorting with blank cells
Post by: rickpqu on August 12, 2015, 07:06:35 pm
Hi, in my ParamQuery table, one column has numbers and blanks. When I sort this column, blank cells appear at the top, and then number cells sorted accordingly. Is there a way to make the number cells to show at the top and the blank cells at the bottom after sorting (both ascending and descending)?
Title: Re: Sorting with blank cells
Post by: paramvir on August 12, 2015, 07:26:58 pm
It can be done in either of 2 ways.

1) Custom sorting. http://paramquery.com/pro/demos/sorting_custom

or

2) Take out the rows with blank values in beforeSort event and append them in sort event.
Similar example: http://paramquery.com/pro/demos/freeze_rows
Title: Re: Sorting with blank cells
Post by: rickpqu on August 13, 2015, 01:25:10 am
Thanks. I tried custom sorting, and I could push null cells to the bottom at ascending sorting. However, when I click the column header again for descending sorting, the null cells came to the top, followed by the highest value cells. I guess that descending sorting just reverses the result of ascending sorting - is there a way to custom sorting for both ascending and descending sorting? I am afraid that the option 2) you suggested might take too much time.
Title: Re: Sorting with blank cells
Post by: paramvir on August 13, 2015, 02:06:25 pm
Custom sorting column.sortType is called during both ascending and descending order.

you might need to set a flag in beforeSort(evt, ui) event during descending order. you can find the current sorting order from ui.sorter[0].dir

http://paramquery.com/pro/api#event-beforeSort

In sortType callback do the reverse when one of the values is blank and sorting is in descending order.
Title: Re: Sorting with blank cells
Post by: rickpqu on August 14, 2015, 02:43:25 am
Thanks. I could solve the problem with using ParamQuery Pro 3's sortModel.sorter and custom sorting (sortType).