Small recommendations:
- It seems to me that you can remove
async: falseparameter for the$.ajaxcall. - You can remove
result.datafrom the data returned by the ajax call. (After that you should and the line withvar colD = result.data). The data will be not really used because you calltrigger('reloadGrid');immediately. - On the other side the values for
sortnameandsortorderparameters should be included in the data model (as the properties ofresult). - You can use
url: secondFetchURL, datatype: 'json', mtype: 'POST'parameters directly in the jqGrid definition ( in$("#myGrid").jqGrid({/*here*/});. Notrigger('reloadGrid')will be needed.
UPDATED: Look at thisthis and thisthis answers. Probably the approach is what you need from the dynamic columns.
You can take a look in the answerthe answer in case if you will need to use custom formatters.