How to hide a jqgrid column dynamically

Sai Avinash picture Sai Avinash · Oct 22, 2013 · Viewed 34.2k times · Source

I am implementing jqgrid in my asp.net MVC web application.

In my grid i have two columns edit and delete. The delete should be visible only if the user is logged as admin .

How can we dynamically hide.show columns in jqgrid. I am having a session variable to check whether the logged in user is Admin or not.

I am accessing that variable in javascript. but, not sure how can i hide/show column in jqgrid

Please help..

Answer

Vinoth Krishnan picture Vinoth Krishnan · Oct 22, 2013

Use this code,

jQuery("#list").jqGrid('hideCol',["colModel1_name","colModel2_name"]);
jQuery("#list").jqGrid('showCol',["colModel1_name","colModel2_name"]);

May this help you.