joeharrison714 / MVCGrid.Net

http://mvcgrid.net
MIT License
74 stars 55 forks source link

Suggestion - Checkbox in first column #107

Open Petrujie opened 7 years ago

Petrujie commented 7 years ago

I would suggest there should be a checkbox to select multiple records.

JRyanJones commented 3 years ago

The cells and their headers support this with HTML:

cols.Add("Check")
    .WithHtmlEncoding(false)
    .WithSorting(false)
    .WithFiltering(false)
    .WithVisibility(true, false)
    .WithHeaderText("<input type='checkbox' id='selectAllCheck'>")
    .WithValueTemplate("<input type='checkbox' class='my-select-class' value='{Model.Id}'>")
    .WithPlainTextValueExpression(p => "");
$(function () {
    $(document.body).on("click", "#selectAllCheck", function (e) {
        var isChecked = $(this).prop("checked");
        $('.my-select-class').each(function () {
            $(this).prop('checked', isChecked);
        });
    });
});