[英]How do I hide a jqGrid column of variable name?
I have a jqGrid column which name may change (is a variable), how do I get the name and hide it? 我有一个jqGrid列,其名称可能会更改(是一个变量),如何获取名称并隐藏它?
Something along the lines of the below (which don't work) 沿着下面的线条(不起作用)
$('#tblGridName').jqGrid('hideCol',4);
or 要么
var infoName = $('.ui-jqgrid-htable th:eq(4)').text();
$('#tblGridName').jqGrid('hideCol',infoName );
You can just use 你可以使用
var cm = myGrid.getGridParam("colModel");
to get the current colModel
. 获取当前的colModel
。 Then cm[4].name
is the name of the column. 然后cm[4].name
是列的名称。 So 所以
var colPos = 4;
var myGrid = $('#tblGridName');
myGrid.jqGrid('hideCol', myGrid.getGridParam("colModel")[colPos].name);
do what you need. 做你需要的。
Sorry, found the answer almost right off. 对不起,差不多找到了答案。
Just amended this 刚修改过这个
var infoName = $('.ui-jqgrid-htable th:eq(4)').text();
$('#tblGridName').jqGrid('hideCol',infoName );
to be 成为
var infoName = $.trim( $('.ui-jqgrid-htable th:eq(4)').text() );
$('#tblGridName').jqGrid('hideCol',infoName );
Any better solutions welcomed. 欢迎任何更好的解决方
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.