Yes, you can dynamically add columns, but the trick is to provide placeholders for them in the colmodel.
1. Provide a number of empty column names in the colModel definition — I used 30, just an arbitrary number, expecting my search results to never require more than this….ensure that they are easily labeled: {name: 'p1', index: 'p1', hidden: true }…{name: 'p30', index:'p30', hidden: true }
2. define the 'datatype: function(postData)' function on your jqgrid to handle the custom loading of the ajax call, which will require you to add the JSON data to the grid yourself using the addJSONData(jsonObject) method with the jsonObject being correctly formatted per your colModel.
3. Inside your datatype function, you can then loop through your returned ajax results and use the below mechanism to dynamically rename and put titles on your hidden 'placeholder' columns (all the p1…p30) that you have defined in the colmodel: