Skip to content
Advertisement

jqGrid cascading drop down change event does not fire

With Oleg and many websites help I have been working on getting cascading data bound drop downs functioning in jqGrid

I have three drop downs: Customer > Project > Task. Changing Customer should reload Project with that Customers Projects. Changing Projects should reload Tasks with that Projects Tasks.

I have actually got Project to reload with that Customers tasks by creating a change event handler in Customer which in turn calls getJson against a URL and then replaces the contents of the Project drop down with the new options. It works great.

I then applied this same logic to the Project drop down, but the Project event does not appear to fire. I have observed the following when changing the Project drop down:

  1. The Task drop down does not change
  2. The Task Json controller event is not called (it is meant to be called by getJSON in the Project change event)
  3. In Firebug, in the Network monitor, the call and response to the Task Json controller event does not appear.
  4. In Firebug it does not hit a breakpoint that I set in the Project change event handler

The Customer event handler however works perfectly, and performs all of the above 4 points as expected when I change the Customer.

I am fairly certain it is not firing the change event against the Project drop down.

If I run the web page and edit and change the Project drop down value as my very first action, it does not fire the project event handler, so I don’t think it is the Customer event resetting the Project event handler.

So, does anyone know why my Customer change event is called but my Project one is not?

Is there a way I can inspect the DOM or something and see if my event has been attached at runtime? is that the way it works?

I am using jqGrid 4.4.1

My jqGrid is setup this way:

  • Uses inline editing
  • click to select dblclick to edit
  • A datepicker is attached the date column
  • Upon edit I get the select db key value out of hidden fields but I’m hoping I can remove that.
  • I have three selects next to each other

Here is the my jqGrid definition

JavaScript

FIXED CODE HERE

I moved the change event handler definition out of the column definition and into the dblclick event handler. It’s still not perfect. I’m sure there is some overhead in attaching the event handler every time, and when Customer is changed, it updates and selects the first Project but clears the Tasks.

JavaScript

Advertisement

Answer

OK, the issue was that in the ondblClickRow event handler I was setting the editoptions / dataUrl property. As I was not also specifying the editoptions / dataEvents property at this point it was basically overwriting the static event handler with nothing.

in the ondblClickRow event handler I was only overwriting Project and Tasks drop down, which explains why the Project handler was being removed and not the Customer one.

Apologies to Oleg: I did not post the full code at the start, so I did not include the double click event.

Anyway Oleg if you can suggest how I can preserve the event handler I can award you the answer. Otherwise I will award this as the answer, even though your help has been invaluable. I’m guessing I might need to move the event handler definition down to the dblclick event handler rather than in the column definition?

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement