Author Topic: Exclude first and last row when sorting (if there is a row)  (Read 380 times)

necatiozbek

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 19
    • View Profile
Exclude first and last row when sorting (if there is a row)
« on: August 27, 2024, 02:25:22 pm »
Hi,
Similar to the topic here > https://paramquery.com/forum/index.php?topic=4795.0  and your answer >https://paramquery.com/pro/demos/freeze_rows


I have special two row. (Id=-1000000  and  Id=  1000000)
These rows appear as the first and last rows when the grid is loaded with two date ranges. and includes previous and subsequent carryover amounts.

I want to do this. If there are Id=-10000 or Id= 10000 rows, do not include them in the sorting.
Keep the line Id=-10000 as the first line, if there is a line Id=10000, leave it as the last line.

Because depending on the user's preference, one or two or none of these lines may be included in the incoming data.

Is it possible ?

Thanks..

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6307
    • View Profile
Re: Exclude first and last row when sorting (if there is a row)
« Reply #1 on: August 27, 2024, 03:14:12 pm »
yes, special rows can be excluded from grid data in beforeSort event and added back in sort event at whatever location you want them.

similar to this example: https://paramquery.com/pro/demos/freeze_rows

necatiozbek

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Exclude first and last row when sorting (if there is a row)
« Reply #2 on: August 27, 2024, 05:10:08 pm »

Can you show me how to freeze the first and last row in the grid as example code?

and how should I ensure it is not affected by the rankings?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6307
    • View Profile
Re: Exclude first and last row when sorting (if there is a row)
« Reply #3 on: August 29, 2024, 11:17:30 pm »
The example is already shared. Have you tried it?

Rows are extracted from grid data using js Array splice method in beforeSort event and added back to grid data using js Array unshift / push methods in sort event.

Reference of js Array methods:

https://www.w3schools.com/jsref/jsref_splice.asp
https://www.w3schools.com/jsref/jsref_unshift.asp
https://www.w3schools.com/jsref/jsref_push.asp