JQGrid:dataEvents中的依赖项下拉列表更改

时间:2012-07-06 18:13:39

标签: events drop-down-menu jqgrid dependencies onchange

我正在开发一个网格,其中包含每个模块的许可列表。

我想要的是在列中的组合框中进行更改时验证每2个事件。我使用1和0来激活/停用

第一种情况:如果我激活“写入”,“修改”,“删除”或“打印”意味着自行选择“阅读”

enter image description here

第二种情况恰恰相反:如果禁用“读取”将自动关闭“写入”,“修改”,“删除”和“打印”

enter image description here

研究我找到了使用输入事件功能的选项:

{"name":"read",
"index":"read",
"width":48,
"resizable":false,
"editable":true,
"edittype":"select",
"editoptions":{
  "value":"0:0;1:1",
  "dataEvents":[{
               "type":"change",
                "fn":function(e){
                     if($(e.target).val() == '0')
                     {
                     // actions here...
                     }
                 }
               }]
 }
}

您可以按行更改其他列的元素吗?

修改

我的解决方案:

$('tr.jqgrow select[name*="read"]').live("change",function()
{   
    if($(this).val() === '0') $(this).closest('tr.jqgrow').find('select.editable').not(this).find('option:first-child').attr("selected", "selected");
});

$('tr.jqgrow select[name!="read"]').live("change",function()
{
    $(this).closest('tr.jqgrow').find('select[name*="read"]').find('option:last-child').attr("selected", "selected");
});

1 个答案:

答案 0 :(得分:0)

the answer中,您将找到一个如何在jqGrid中实现依赖选择的示例。顺便说一句,你可以使用formatter: "checkbox"相同的想法。在这种情况下,实施将更容易。您必须手动修改<select>元素或chachbox ,这一点非常重要。

One more answer可以显示另一个可以使用的实现选项。

相关问题