In Jqgrid you apply a required attribute to any given field like this
{ name: 'Comments', index: 'Comments', editable: true, editrules: { required: true }, edittype: 'textarea' }
How would I go about doing this dynamically?
I’d like to make a field required, based on another field (like the selected value of a dropdown/combobox)
I know where to place the code, eg, my dropdown’s select event. But not how to apply the required attribute in any other way other than the code sample I supplied..
I suggest that you use some event to monitor the changes in the select control and change the value of the
requiredoption of editrules.For example in the demo I used ‘focusout’ event on the select control of ‘ship_via’ column to change the
requiredoption of editrules of the column ‘note’. I used the ‘focusout’ event because the code used the bug fix which I suggested here. You can use other events alternatively, but you should test there in different browsers.The code which I used in the demo is