Author Topic: Trouble with filtering and saving grid data  (Read 2478 times)

ralph1996

  • Pro Ultimate
  • Jr. Member
  • *
  • Posts: 80
    • View Profile
Trouble with filtering and saving grid data
« on: August 24, 2017, 11:20:28 pm »
Our aspx page contains an array of data that contains the necessary fields to define a ParamQuery grid event data.  We create a GridRenderer object that contains stores this data and initializes the ParamQuery grid.  It also is used to extract all of the data out of the grid after the grid has been edited.  Extracting the data is basically just returning the "data" array that is used when initializing the ParamQuer grid.  My experience was that this array is kept up to date with all changes during editing.

This has all worked fine until we decided we want to be able to allow some filtering on the grid as well.  We are not using header filtering but instead have a link on our page that triggers a filter event.  We only filter on a single column (isDeleted) and it is a boolean state (true/false).  The goal is to allow users to toggle between showing only their active events and showing all of their events including deleted events.

The filtering actually works fine, the problem is that when we add a new row to the grid using addRow the row gets added in the grid properly, but when we call the extract function on our GridRenderer the new row data is not there.  Without filtering this all worked fine.

I am sure I am missing something relevant regarding how to pull ALL the data (including added rows) when filtering is active.  I also tried using grid.getChanges to see if I could get the added rows, but that method returned no changes.

I am attaching a text file with javascript code that displays all the relevant parts. You can see in the colModel of the grid that we set a filter on the isDeleted column without setting on to true.  Addign a row in this condition works fine, it is only when you set the filter to on = true that adding the row no longer adds teh row to the data array in the dataModel.

Thank you for your help....

ralph1996

  • Pro Ultimate
  • Jr. Member
  • *
  • Posts: 80
    • View Profile
Re: Trouble with filtering and saving grid data
« Reply #1 on: August 24, 2017, 11:45:22 pm »
ONe other note.  I realized I did nto have TrackChanges on when I tried to use the getChanges method.  Once I did this I do see the changes if I call getChanges in the extract method of the GridRenderer  - However, even if I call commit - the data object still does not have the new row.

Now that I have teh added row, I could append it to the array manually, but I think that is wrong since in the unfiltered case teh row does get added automatically.

ralph1996

  • Pro Ultimate
  • Jr. Member
  • *
  • Posts: 80
    • View Profile
Re: Trouble with filtering and saving grid data
« Reply #2 on: August 25, 2017, 01:10:57 am »
HI, I did some debugging through the paramQuery code and found that if I concatentate the

grid.options.dataModel.data with grid.options.dataModel.dataUF I get all the data including filtered, unfiltered and new records.  So I can probably do this.

I am just not sure this is the "BEST" or "CORRECT" way to do this.  I woudl prefer not implementing someting that may break in a future release.

Thanks!

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6297
    • View Profile
Re: Trouble with filtering and saving grid data
« Reply #3 on: August 25, 2017, 03:59:22 pm »
That's correct though you may also use grid.getData() method for that.

https://paramquery.com/pro/api#method-getData