The js code is as follows: add property settings in the initAllGrid function colModel1: frozen: true ; then add $("#"+gridType+"_grid").jqGrid('setFrozenColumns') ; That's it.
eastcom.modules.workorderQuery = ( function () { // Other methods omitted ... // Initialize all grid function initAllGrid(){ var colModel1 = [{label:'frozen column 1-test11',name:'order_id',index:'order_id', width:170, align:"center",sortable: false ,frozen: true // This column is frozen when sliding },{label:'frozen column 2-test22',name:'alarmfrom_type',index:'alarmfrom_type', width:120, align:"center",sortable: false ,frozen: true // This column is frozen when sliding },{label:'prefecture',name:'order_city',index:'order_city', width:70, align:"center",sortable: false },{ label: 'District',name:'order_county',index:'order_county', width:70, align:"center",sortable:false },{label:'网络分类',name:'order_typedes',index:'order_typedes', width:90, align:"center",sortable:false }]; _initGrid('task_con_grid_div',colModel1); } // Method of initializing grid function _initGrid(gridType,colModel){ // $("#"+gridType+"_grid" ).jqGrid({ height: 470, rowNum : 15, datatype: "local", autowidth : false, shrinkToFit : false, autoScroll: true, colModel:colModel, pager: "#"+gridType+"_gridPager", loadComplete:function(){ eastcom.syncIframeHeight(); $('body').unmask(); } }); $( "#"+gridType+"_grid").jqGrid('setFrozenColumns'); // This column is frozen when sliding } // Load function init(){ at initialization ...... initAllGrid(); ...... } return { init : init, ...... }; })();
Thanks for sharing
Reference URL: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:frozencolumns