0

I have a list of checkboxes in my kendo grid.Select all option is also there. Problem is When i click select all then all the checkboxes selected and then unselect some checkboxes and going to save then it shows me all the checkboxes.(un checked checkboxes also shown )

My Code

    $('#itemGrid').on('change', '.usedchk', function () {


    var checked = $(this).is(':checked');
    var grid = $('#itemGrid').data().kendoGrid;
    var dataItem = grid.dataItem($(this).closest('tr'));
    var selected = $('#selected').val();
    var id = dataItem.itemId;

    if ($('#selected').val().indexOf(id) == -1) {
        if ($('#selected').val() == '') {
            $('#selected').val(id);
        } else {
            $('#selected').val(selected + "," + id );
        }
    }
});

1 Answer 1

1

use below code on save, to get all checked checkboxes as a comma separated string

var output = $.map($('#selected:checked'), function(n, i){
  return n.value;
}).join(',');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.