隐藏展开/折叠符号或停用规范.jqGrid 子网格中的行 [英] Hide expand/collapse symbol or deactivate spec. rows in jqGrid subgrid

查看:15
本文介绍了隐藏展开/折叠符号或停用规范.jqGrid 子网格中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有子网格的网格:只有主网格的第一行需要有子网格.

我通过 Google 和 查看相应的示例).请务必了解,loadComplete 事件将在任何页面上都可以调用,因此在第二页上,您也只会在第一行上拥有 subrgid.

如果您需要在选择需要具有子网格的行时实现更复杂的逻辑,您可以使用以下代码

loadComplete: function() {var grid = $("#list");var subGridCells = $("td.sgcollapsed",grid[0]);$.each(subGridCells,function(i,value){如果(我!==0){$(value).unbind('click').html('');}});}

上面的代码和语句$("td.sgcollapsed:not(:first)","#list").unbind('click').html(''),但您可以轻松修改最新版本的代码以实现更复杂的行为.

已更新:如果您只需要对由 rowid 标识的某些行使用有损子网格,则可以使用

$("#"+rowid+" td.sgcollapsed",grid[0]).unbind('click').html('');

(见 这里)里面的 加载完成.如果您需要为所有 id 不等于 rowid 的行停用子网格,您可以进行如下操作

$('td.sgcollapsed:not("#'+rowid+'td.sgcollapsed")',grid[0]).unbind('click').html('');

(见现场这里)

更新:free jqGrid 现在有新功能答案:hasSubgrid回调,可以在subGridOptions中指定.它允许通知 jqGrid 哪些行不应该有子网格.

I have a grid with a subgrid: Only the first row of the Main grid need to have a subgrid.

The solutions I found by Google and http://www.trirand.com/....i:subgrid&s[]=hidecol doesn't work.

Is there a quick and dirty (hard coded) solution?

解决方案

Hiding the 'subgrid' column with jQuery("#grid_id").hideCol('subgrid'); remove full column which can be used to expand or collapse the subgrid, so you can not use the way in your case.

I suggest you to clear contain of the 'subgrid' column and unbind the 'click' event for the cells inside of loadComplete event handle:

loadComplete: function() {
    $("td.sgcollapsed:not(:first)","#list").unbind('click').html('');
}

you will have the following results: (You can see the corresponding example live here). It's important to understand, that the loadComplete event will be called on any page, so on the second page you will have subrgid also only on the first row.

If you need to implement more complex logic in choosing of the rows which need have subgrids you can use following code

loadComplete: function() {
    var grid = $("#list");
    var subGridCells = $("td.sgcollapsed",grid[0]);
    $.each(subGridCells,function(i,value){
        if (i!==0) {
            $(value).unbind('click').html('');
        }
    });
}

The code above do the same as the statement $("td.sgcollapsed:not(:first)","#list").unbind('click').html(''), but you can easy modify the last version of the code to implement more complex behavior.

UPDATED: If you need detractive subgrid only for some row identified by the rowid you can use

$("#"+rowid+" td.sgcollapsed",grid[0]).unbind('click').html('');

(see live here) inside of the loadComplete. If you need deactivate subgrid for all rows which id is not equal to rowid you can make something like following

$('td.sgcollapsed:not("#'+rowid+' td.sgcollapsed")',grid[0]).unbind('click').html('');

(see live here)

UPDATED: free jqGrid now have new feature described in the answer: hasSubgrid callback which can be specified in subGridOptions. It allows to inform jqGrid which rows should don't have subgrids.

这篇关于隐藏展开/折叠符号或停用规范.jqGrid 子网格中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆