Editing jqGrid using generated field disconnections based on the value of another field

When the user clicks on β€œEdit” in jqGrid, the form that opens has several lists and text fields. Depending on the value in the List field, several text fields should be disabled or set to read only when the form is loaded.

I have a part working for the onChange event in the list to switch text fields to disabled / activated, but I'm trying my best to do this on form loading. I tried using aftershowform, which already has an event handler, so I created another event, like aftershowform2, and attached this event, and the event handler fires. But the problem is that the lists are dynamically loaded by calling Ajax (dataurl of editoptions) and aftershowform until these lists are populated with parameters. Is there another event that fires after lists are loaded? The entire application is framework-controlled and difficult to insert.

0
jqgrid
source share
1 answer

I see many ways in which you can fulfill your requirements.

The first and best, in my opinion, will be the use of dataEvents editoptions with type:'change' (see this as an example). The corresponding code may be

 editoptions: { dataUrl:..., dataEvents: [ { type: 'change', fn: function(e) { var v=$(e.target).val(); alert(v); // do something with selected item value } } ] } 

The binding to the functions defined by dataEvents will be after the successful return of select from the server.

Another way is to change your current implementation to replace jQuery.bind with jQuery.live (see code template here ).

+1
source share

Source: https://habr.com/ru/post/650815/


All Articles