本文介绍了在asp.net中冻结JQGrid中的列c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 如何冻结或冻结jqgrid中的前两列。? 我的代码在下面,并且一切正常。但我必须使用冻结或冻结属性设置前两列的固定位置,所以请提前帮助谢谢.. function loadGrid (){ $( #loading)。show(); $ .ajax({ type: POST, url: BranchMasterReport.aspx / LoadData, contentType: application / json; charset = utf-8, datatype: json, async : true ,成功:函数(结果){ result = result.d; if ( result == empty){ showMsg( 未找到任何记录。!, 错误); $( #loading)。fadeOut( slow); return ; } jQuery( #grid)。jqGrid({数据类型: local, colNames:[' BRANCH_ID' ,' 分支名称' ,' 分支类型' ,' 分支类型' , ' 分支代码' ,' 地址' ,' 电子邮件' ,' 电话号码 ,' Pincode ' ,' 州' ,' City' ,' 备注' ,' 输入日期' ,' STATE_ID' ,' CITY_ID' ,' MAIN_BRANCH_ID' ], colModel:[ {name: BRANCH_ID,键: true ,索引: BRANCH_ID,可排序: false ,隐藏: true ,冻结: true }, {name: BRANCH_NAME,可排序: false ,已冻结: true }, { name: BRANCH_TYPE,隐藏: true }, {name: SUB_BRANCH_TYPE,对齐: left,width: 200 }, {name: BRANCH_CODE,宽度: 100 }, {name: ADDRESS,width: 400 }, {name: EMAIL,width: 280 }, { name: TELEPHONE_NO,宽度: 100 ,对齐: center}, {name: PINCODE,width: 70 ,对齐: center}, {name: STATE,align: center,width: 85 }, {name: CITY}, {name: 备注,可排序: false ,宽度: 250 }, {name: ENTRYDATE,align: center,width: 90 }, {name: STATE_ID,index: STATE_ID,可排序: false ,隐藏: true }, {name: CITY_ID,index: CITY_ID,可排序: false ,隐藏: true }, {name: MAIN_BRANCH_ID,index: MAIN_BRANCH_ID,可排序: false ,隐藏: true } ],数据:JSON.parse(结果), rowNum: 20 , modal: true , jsonReader:{repeatitems: true }, shrinkToFit: false , frozenColumns: true , // ReorderCoulmns:true, // excel:true, ignoreCase: true , // forceFit:true, hidegrid: false , emptyrecords: 没有要查看的记录, multiselect: true , rownumbers: true , // gridview:true, loadonce: true , rowList:[ 20 , 50 , 100 ],寻呼机: #pager, // viewrecords:true, autowidth: true , // sortname:'BRANCH_NAME', // sortorder:asc, // height :Math.max(0,document.documentElement.clientHeight - 300), height:' auto', width:' auto', altRows: true , hoverows: true , // 搜索:true, // toppager:false, // cloneToTop:true, sortable: true , // sortable:{ // update:function(perm){ // if(perm){ // $(#grid)。jqGrid(remapColumns,perm,true); // var colModels = $(#grid)。getGridParam (colModel); // } // } // }, autoencode: true , pagerpos:' center', loadtext: 正在加载...,标题:' Branch Master报告', loadui:' block' }) ; $(' #grid')。jqGrid(' navGrid',' # pager',{ edit: false , add : false , del: false , search: false , searchtext: 搜索, addtext: 添加, edittext: 编辑, deltext: 删除, cloneToTop: false },{},{},{},{multipleSearch: false ,closeAfterSearch: true ,closeOnEscape: true }); $( #grid)。jqGrid(' filterToolbar',{stringResult: true ,searchOnEnter: false ,defaultSearch: cn,overlay: false }); jQuery( #grid)。triggerHandler( jqGridAfterGridComplete); jQuery( #grid)。jqGrid(' setFrozenColumns'); },错误:函数(错误){ alert(error.d); $( #loading)。fadeOut( slow); } }); $( #loading)。fadeOut( slow); } 解决方案 ( #loading)。show(); .ajax({ type: POST, url: BranchMasterReport.aspx / LoadData, contentType: application / json; charset = utf-8,数据类型: json, async : true ,成功:函数(结果){ result = result.d; if (result == 空){ showMsg( 找不到记录。!, error); ( #loading)。fadeOut( 慢); return ; } jQuery( #grid)。jqGrid({数据类型: local, colNames:[' BRANCH_ID' ,' 分支名称' ,' 分支类型' ,' 分支类型' , ' 分支代码' ,' 地址' ,' 电子邮件' ,' 电话号码 ,' Pincode ' ,' 州' ,' City' ,' 备注' ,' 输入日期' ,' STATE_ID' ,' CITY_ID' ,' MAIN_BRANCH_ID' ], colModel:[ {name: BRANCH_ID,键: true ,索引: BRANCH_ID,可排序: false ,隐藏: true ,冻结: true }, {name: BRANCH_NAME,可排序: false ,已冻结: true }, { name: BRANCH_TYPE,隐藏: true }, {name: SUB_BRANCH_TYPE,对齐: left,width: 200 }, {name: BRANCH_CODE,宽度: 100 }, {name: ADDRESS,width: 400 }, {name: EMAIL,width: 280 }, { name: TELEPHONE_NO,宽度: 100 ,对齐: center}, {name: PINCODE,width: 70 ,对齐: center}, {name: STATE,align: center,width: 85 }, {name: CITY}, {name: 备注,可排序: false ,宽度: 250 }, {name: ENTRYDATE,align: center,width: 90 }, {name: STATE_ID,index: STATE_ID,可排序: false ,隐藏: true }, {name: CITY_ID,index: CITY_ID,可排序: false ,隐藏: true }, {name: MAIN_BRANCH_ID,index: MAIN_BRANCH_ID,可排序: false ,隐藏: true } ],数据:JSON.parse(结果), rowNum: 20 , modal: true , jsonReader:{repeatitems: true }, shrinkToFit: false , frozenColumns: true , // ReorderCoulmns:true, // excel:true, ignoreCase: true , // forceFit:true, hidegrid: false , emptyrecords: 没有要查看的记录, multiselect: true , rownumbers: true , // gridview:true, loadonce: true , rowList:[ 20 , 50 , 100 ],寻呼机: #pager, // viewrecords:true, autowidth: true , // sortname:'BRANCH_NAME', // sortorder:asc, // height :Math.max(0,document.documentElement.clientHeight - 300), height:' auto', width:' auto', altRows: true , hoverows: true , // 搜索:true, // toppager:false, // cloneToTop:true, sortable: true , // sortable:{ // update:function(perm){ // if(perm){ // How to freeze or frozen first 2 column in jqgrid.?my code is below and it's all working fine. but i have to set fix position of first two columns using freeze or frozen properties so please help thanks in advance.. function loadGrid() { $("#loading").show(); $.ajax({ type: "POST", url: "BranchMasterReport.aspx/LoadData", contentType: "application/json; charset=utf-8", datatype: "json", async: true, success: function (result) { result = result.d; if (result == "empty") { showMsg("no records found.!", "error"); $("#loading").fadeOut("slow"); return; } jQuery("#grid").jqGrid({ datatype: "local", colNames: ['BRANCH_ID' , 'Branch Name' , 'Branch Type' , 'Branch Type' , 'Branch Code' , 'Address' , 'Email' , 'Telephone No' , 'Pincode' , 'State' , 'City' , 'Remark' , 'Entry Date' , 'STATE_ID' , 'CITY_ID' , 'MAIN_BRANCH_ID' ], colModel: [ { name: "BRANCH_ID", key: true, index: "BRANCH_ID", sortable: false, hidden: true, frozen: true }, { name: "BRANCH_NAME" ,sortable: false, frozen: true}, { name: "BRANCH_TYPE", hidden: true }, { name: "SUB_BRANCH_TYPE", align: "left", width: 200 }, { name: "BRANCH_CODE", width: 100 }, { name: "ADDRESS", width: 400 }, { name: "EMAIL", width: 280 }, { name: "TELEPHONE_NO", width: 100, align: "center" }, { name: "PINCODE", width: 70, align: "center" }, { name: "STATE", align: "center", width: 85 }, { name: "CITY" }, { name: "REMARK", sortable: false, width: 250 }, { name: "ENTRYDATE", align: "center", width: 90 }, { name: "STATE_ID", index: "STATE_ID", sortable: false, hidden: true }, { name: "CITY_ID", index: "CITY_ID", sortable: false, hidden: true }, { name: "MAIN_BRANCH_ID", index: "MAIN_BRANCH_ID", sortable: false, hidden: true } ], data: JSON.parse(result), rowNum: 20, modal: true, jsonReader: { repeatitems: true }, shrinkToFit: false, frozenColumns : true, //ReorderCoulmns : true, //excel: true, ignoreCase: true, // forceFit: true, hidegrid: false, emptyrecords: "No records to view", multiselect: true, rownumbers: true, //gridview: true, loadonce: true, rowList: [20, 50, 100], pager: "#pager", //viewrecords: true, autowidth: true, //sortname: 'BRANCH_NAME', //sortorder: "asc", //height: Math.max(0, document.documentElement.clientHeight - 300), height: 'auto', width: 'auto', altRows: true, hoverows: true, //search: true, //toppager: false, //cloneToTop: true, sortable: true, //sortable: { // update: function (perm) { // if (perm) { // $("#grid").jqGrid("remapColumns", perm, true); // var colModels = $("#grid").getGridParam("colModel"); // } // } //}, autoencode: true, pagerpos: 'center', loadtext: "Loading...", caption: 'Branch Master Report', loadui: 'block' }); $('#grid').jqGrid('navGrid', '#pager', { edit: false, add: false, del: false, search: false, searchtext: "Search", addtext: "Add", edittext: "Edit", deltext: "Delete", cloneToTop: false }, {}, {}, {}, { multipleSearch: false, closeAfterSearch: true, closeOnEscape: true }); $("#grid").jqGrid('filterToolbar', { stringResult: true, searchOnEnter: false, defaultSearch: "cn", overlay: false }); jQuery("#grid").triggerHandler("jqGridAfterGridComplete"); jQuery("#grid").jqGrid('setFrozenColumns'); }, error: function (error) { alert(error.d); $("#loading").fadeOut("slow"); } }); $("#loading").fadeOut("slow"); } 解决方案 ("#loading").show();.ajax({ type: "POST", url: "BranchMasterReport.aspx/LoadData", contentType: "application/json; charset=utf-8", datatype: "json", async: true, success: function (result) { result = result.d; if (result == "empty") { showMsg("no records found.!", "error");("#loading").fadeOut("slow"); return; } jQuery("#grid").jqGrid({ datatype: "local", colNames: ['BRANCH_ID' , 'Branch Name' , 'Branch Type' , 'Branch Type' , 'Branch Code' , 'Address' , 'Email' , 'Telephone No' , 'Pincode' , 'State' , 'City' , 'Remark' , 'Entry Date' , 'STATE_ID' , 'CITY_ID' , 'MAIN_BRANCH_ID' ], colModel: [ { name: "BRANCH_ID", key: true, index: "BRANCH_ID", sortable: false, hidden: true, frozen: true }, { name: "BRANCH_NAME" ,sortable: false, frozen: true}, { name: "BRANCH_TYPE", hidden: true }, { name: "SUB_BRANCH_TYPE", align: "left", width: 200 }, { name: "BRANCH_CODE", width: 100 }, { name: "ADDRESS", width: 400 }, { name: "EMAIL", width: 280 }, { name: "TELEPHONE_NO", width: 100, align: "center" }, { name: "PINCODE", width: 70, align: "center" }, { name: "STATE", align: "center", width: 85 }, { name: "CITY" }, { name: "REMARK", sortable: false, width: 250 }, { name: "ENTRYDATE", align: "center", width: 90 }, { name: "STATE_ID", index: "STATE_ID", sortable: false, hidden: true }, { name: "CITY_ID", index: "CITY_ID", sortable: false, hidden: true }, { name: "MAIN_BRANCH_ID", index: "MAIN_BRANCH_ID", sortable: false, hidden: true } ], data: JSON.parse(result), rowNum: 20, modal: true, jsonReader: { repeatitems: true }, shrinkToFit: false, frozenColumns : true, //ReorderCoulmns : true, //excel: true, ignoreCase: true, // forceFit: true, hidegrid: false, emptyrecords: "No records to view", multiselect: true, rownumbers: true, //gridview: true, loadonce: true, rowList: [20, 50, 100], pager: "#pager", //viewrecords: true, autowidth: true, //sortname: 'BRANCH_NAME', //sortorder: "asc", //height: Math.max(0, document.documentElement.clientHeight - 300), height: 'auto', width: 'auto', altRows: true, hoverows: true, //search: true, //toppager: false, //cloneToTop: true, sortable: true, //sortable: { // update: function (perm) { // if (perm) { // 这篇关于在asp.net中冻结JQGrid中的列c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-30 07:07