jqGrid复选框事件 [英] jqGrid checkbox events

查看:2777
本文介绍了jqGrid复选框事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个jqGrid它在行中有一个复选框。我需要能够更改值,如果它被检查或取消选中。在$(document).ready块中使用this不起作用。我试过多个解决方案,我在论坛上发现,似乎没有什么工作。任何建议?

I have a jqGrid it has a checkbox in the rows. I need to be able to change the value depending of if it is being checked or unchecked. Using this in the $(document).ready block does not work. I have tried multiple solutions that I have found on the forum and nothing seems to work. Any suggestions?

 $('#glReportCodesGrid').children("input:checkbox").click(function () {
    var y = $(this).val();
    if (y == 'false') {
        $(this).val('true');
    }
    else { $(this).val('false'); }
});


推荐答案

您需要使用以下选择器来找到复选框:

You need to use the following selector to find the checkboxes:

jQuery(".jqgrow td input", "#glReportCodesGrid").click(function () {

您需要从网格初始化后触发的网格事件中调用上述操作。

You would need to call the above from one of the grid events that is triggered after the grid is initialized.

或者,您也可以使用 jQuery.delegate 动态在创建元素时绑定事件处理程序:

Alternatively, you can use jQuery.delegate to dynamically bind the event handler when the elements are created:

jQuery(document).delegate(
    '#glReportCodesGrid .jqgrow td input', 
    'click', 
    function () { ... });

问题 jqgrid-with-an-editable-checkbox栏有一些您可能会有帮助的相关资讯。

The question jqgrid-with-an-editable-checkbox-column has some related information that you may find helpful.

这篇关于jqGrid复选框事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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