0

I need to setup jqGrid in the way, that it respects active filter during adding new row. In the printscreen bellow, there is active filter for Workplace=L40. I need to have the same filter active (L40 in this case) in the automatically created "Add record" window, so users do not have to select the same workplace again and again.

I do not know, how to do it, I have found nothing on Google. Can you help me pls?

Printscreen

Milan Švec
  • 1,675
  • 17
  • 21
  • 1
    Oleg, the JQGrid master explains how to set default values in the popup form here: https://stackoverflow.com/questions/7943924/how-to-set-default-field-values-for-add-form-in-jqgrid-from-current-row – Nick.Mc Oct 28 '20 at 10:27

1 Answers1

0

It seems that the fork of jqGrid the free-jqGrid is not supported anymore. In this case I can just give you some advice.

The idea is simple. In case if you have active search filter with certain field (in your case Workplace) , you can simple set the defaultValue option in editoptions. Since there is a missing documentation for free-jqGrid I can recommend you to see the docs for the supported Guriddo jqGrid here, but you should take care.

Common description of the above.

  1. Set the recreateForm to true when add a record
  2. Check if the search is active (search option is true)
  3. If this is active get the filters parameter and extract the field and value
  4. Change the editoptions defaultValue of that field in before beforeInitData event (of course if this exists in free-jqGrid) using setGridParam method

At first look it seems complicated, but it is not.

If you have any problems with this I can try to prepare a example using Guriddo jqGrid

Tony Tomov
  • 3,122
  • 1
  • 11
  • 18