禁用/基于列的值启用剑道格的复选框 [英] Disable/Enable the checkbox in kendo grid based on column Value

查看:199
本文介绍了禁用/基于列的值启用剑道格的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个kendogrid所有工作不错,现在我得到了新的要求,即最后一栏,我有复选框,只是到previous专栏中,我有一个状态栏,

I have a kendogrid all working good, now I got new requirement i.e. last column i have checkbox and just to that previous column I have a status column,

如果该文本值为认证的只有在特定行复选框应该被启用,如果文本没有CERTIFIED应该禁止该行的复选框,不应该允许使用jQuery检查复选框,我附上kendogrid我有,这可能有助于您的任何建议的图片

if that text value is "CERTIFIED" only then that specific row checkbox should be enabled, if the text is not 'CERTIFIED' it should disable the checkbox of that row,and should not allow to check that checkbox using jquery, I have attached pic of kendogrid I have, which might help for any suggestions

code

这是我的我的KENDO GRID

, columns: [
            { field: "ResultFormatID", Title: "ResultFormatID", filterable: false, sortable: false, hidden: true },
            { field: "ID", Title: "ID", filterable: false, sortable: false, hidden: true },
            { field: "RowID", Title: "RowID", filterable: false, sortable: false, hidden: true },
            { field: "BillNumber", Title: "Bill Number", filterable: false, sortable: false, hidden: true },
            { field: "ServiceName", Title: "Service Name", width: 600 },
            { field: "Status", Title: "Service Status", width: 150 }
             , {
               template: $("#template").html(),
               headerTemplate: '<label>  <input type="checkbox" id="checkAll"/>Download</label>', filterable: false, sortable: false, width: 100,
           }
         ]

这是我个人ROW复选框

<script id="template" type="text/kendo-template">
   #if(ResultFormatID != 3) { #   
   <input type="checkbox" #= data.Action ? checked="checked" : "" #  class=\"check_row\"/>
   # } else { #
<input type="button" class="k-button info" name="info" value="Preview" />
   # } #

更新时间:

这是我的CHECKALL功能(和我因取消)

 $("#checkAll").on('click', function (e) {
         debugger;

        var $cb = $(this);
        var checked = $cb.is(':checked');
        var grid = $('.Grid_table').data('kendoGrid');

        grid.table.find("tr").find("td:last input").attr("checked", checked);           


        var items = $(".Grid_table").data("kendoGrid").dataSource.data();
        for (i = 0; i < items.length; i++) {
            var item = items[i];
       var status = item.ServiceStatus;

            if (status == "Result Certified ") {
              grid.table.find("tr").find("td:last input").attr("checked", checked);
            }
            else {

                grid.table.find("tr").find("td:last input").prop("checked",false);
            }
     if (!checked) {
            // debugger;
            $(".Grid_table").data("kendoGrid").clearSelection();
        }

    });

});

更新2

现在,按您的code,一切工作正常,我能取消的未认证行,我面临的一个问题,下面code,如果ATLEAST单个复选框未选中它禁用按钮,用于下载的PDF文件,现在如果我选择所有的复选框,并单击该按钮上下载,它现在被禁用!但如果我取消任何一个排出来像10行,然后下载启用和用于下载该文件。

now as per your code, everything works fine and I am able to uncheck the not certified row, i am facing a problem with below code, if atleast single checkbox is not checked it disabled the button which is used to download the PDF file, now if i select all checkbox and clicked on that button download, it is disabled now!! but if i uncheck any one row out of like 10 rows, then download enables and used to download the file.

如果我禁用低于code中的最后3行中,它有助于使右键单击,但我需要取消选择ATLEAST单个复选框来工作,如果不是会被禁用,我究竟做错了什么? ?

if I disable the last 3 lines of below code, it helps in enabling the button to click, but i need to unselect atleast single check box to work, if not it will disabled, what am i doing wrong ??

 $(function () {
         //debugger;            
        var checkboxes = $(':checkbox:not(#checkAll)').click(function (event) {
            $('#btn_Print').prop("disabled", checkboxes.filter(':checked').length == 0);
        });
        $('#checkAll').click(function (event) {
            checkboxes.prop('checked', this.checked);
            $('#btn_Print').prop("disabled", !this.checked)
        });
    });

如果

推荐答案

看来你需要的,如果输入字段中输入=正在控制什么复选框禁用。所以,你应该定义模板如下:

Seems that what you need is controlling if the input field of type="checkbox" is disabled. So you should defined the template as follow:

<script id="template" type="text/kendo-template">
   #if(ResultFormatID != 3) { #   
   <input type="checkbox" #= data.Action ? checked="checked" : "" #  class=\"check_row\" #= data.Status == 'Certified' ? disabled='disabled' : "" #/>
   # } else { #
<input type="button" class="k-button info" name="info" value="Preview" />
   # } #
</script>

即:添加 data.Status =='认证'的状况?禁用=禁用:

看到它在这里的行动: http://jsfiddle.net/Hfk3Q/

See it in action here: http://jsfiddle.net/Hfk3Q/

修改:在点击标题时,需要更改复选框将改变其实施检查,只有那些没有被禁用的细胞。是这样的:

EDIT: Changes required when clicking on headers check box would be changing its implementation for checking only those cells that are not disabled. Something like:

$('.check_row:not(:disabled)', grid.tbody).prop('checked', true);

看到它在这里的行动: http://jsfiddle.net/Hfk3Q/3/

这篇关于禁用/基于列的值启用剑道格的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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