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

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

问题描述

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

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

我通过Google和 http://www.trirand.com/....i:subgrid&s [] = hidecol 不起作用.

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?

推荐答案

使用jQuery("#grid_id").hideCol('subgrid');隐藏'subgrid'列会删除可用于展开或折叠子网格的完整列,因此您无法在自己的方式中使用情况.

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.

我建议您清除"subgrid"列的包含,并取消绑定

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('');
}

您将得到以下结果: (您可以在此处看到相应的示例).重要的是要理解, loadComplete 事件将可以在任何页面上调用,因此在第二页上,您也只会在第一行上看到subrgid.

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('');
        }
    });
}

上面的代码与语句$("td.sgcollapsed:not(:first)","#list").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.

已更新:如果只需要对rowid标识的某些行使用破坏性的子网格,则可以使用

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('');

(请参见loadComplete内的实时此处) .如果您需要为所有ID不等于rowid的行取消激活子网格,则可以执行以下操作

(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('');

(请参见实时此处)

已更新:免费jqGrid 现在具有以下功能: 答案:hasSubgrid回调,可以在subGridOptions中指定.它可以通知jqGrid哪些行不应该包含子网格.

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天全站免登陆