简体   繁体   English

如何检测何时选择了行并且在jqgrid中选择了非行?

[英]How can I detect when a row is selected and non of rows is selected at jqgrid?

I have a disabled button at my page. 我的页面上有一个禁用按钮。 When a row selected at my grid I want to enable it. 当我在网格中选择一行时,我想启用它。 If any of rows is not selected it should be return to disable too. 如果未选择任何行,则应返回禁用状态。 ,

How can I detect when a row is selected and non of rows is selected at jqgrid? 如何检测何时选择了行并且在jqgrid中选择了非行?

If you use multiselect: true option you should do the following 如果使用multiselect: true选项,则应执行以下操作

onSelectRow: function (id) {
    var selRows = $(this).jqGrid('getGridParam','selarrrow');
    if (selRows.length === 0) {
        alert ("no rows are selected now");
        // you can disable the button
    } else {
        alert ("a row is selected now");
        // you can disable the button
    }
}

additionally you should include in the loadComplete the code which disable of the button because at the beginning, after changing the sort order or after filtering (if you use it) the rows will be not selected. 另外,你应该在loadComplete中包含禁用按钮的代码,因为在开始时,在更改排序顺序之后或在过滤之后(如果使用它),行将不会被选中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM