简体   繁体   中英

Get All Checked Child Items Kendo Grid

I have a Kendo grid that has Child elements as shown in the Image below. Is there a way to read the elements that are checked.

在此处输入图片说明

It depends on when you want to find out what checkboxes are selected, but essentially it will work this way.

You simply add a listener to a button or a common class among the checkboxes that looks at the checkboxes and returns the checked ones.

The example from Kendo: http://dojo.telerik.com/UhANu

Specifically,

$("#showSelection").on("click", function () {
        var checked = [];
        for(var i in checkedIds){
            if(checkedIds[i]){
                checked.push(i);
            }
        }

        alert(checked);
    });

I've changed the above to a .on() instead of .bind because it's what I'm more familiar with being the idiomatic way of doing listeners, but both technically work.

If you'd rather have value of the checkboxes save each time you change them it'd be something like this:

$(".checkbox").on("click", function () {
        var checked = [];
        for(var i in checkedIds){
            if(checkedIds[i]){
                checked.push(i);
            }
        }

        $('#checked-boxes').val(checked);
    });

and in your html create an element that holds the values:

<label for="checked-boxes">Checkboxes that have been selected:</label>
<input type="text" id="checked-boxes" name="checked-boxes">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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