This is a migrated thread and some comments may be shown as answers.

Select ALL check box

1 Answer 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
James
Top achievements
Rank 1
James asked on 17 Sep 2012, 06:22 PM
I cannot get the  grid to clear or check the checkboxes. The line below no worko. Any ideas? 

$('checkedRecords').removeAttr("CHECKED");


checkAll checkbox above grid and grid column to check/uncheck

            <div id="divClaimGrid" style="padding-left: 3px;">
                <span><input  id='checkAll' type='checkbox'  checked="true"/> Check All</span>
                @(Html.Telerik().Grid<SAM.Framework.Utilities.CloneClasses.vxClaimBO>(Model.VXClaimBOs).Name("ClaimsGrid")
                    .Columns(columns =>
                    {
                      columns.Bound(column => column.ClaimID)
                          .Template(@<text><input type='checkbox' name='checkedRecords' value='@item.ClaimID' checked="checked" /></text>)
                          .Title("").Width(36).HtmlAttributes(new { style = "text-align:center" })
                          .ClientTemplate("<input type='checkbox' name='checkedRecords' checked='checked' value='<#= ClaimID #>'")
                          .Sortable(false)
                          .Filterable(false);
                      columns.Bound(column => column.ClaimNo).Width(65).Title("Claim No")

blah... blah...rest of grid

Script on page:
        $(document).ready(function () {
          $('#checkAll').click(function () {
            debugger;
            if (this.checked)
              $("#ClaimsGrid > tbody > input:checkbox").attr("checked", "checked");
            else {
              //$("#ClaimsGrid > tbody > input:checkbox").removeAttr("CHECKED");
              $('checkedRecords').removeAttr("CHECKED");
            }
          });
        });

1 Answer, 1 is accepted

Sort by
0
James
Top achievements
Rank 1
answered on 17 Sep 2012, 06:28 PM
Got it!

        $(document).ready(function () {
          $('#checkAll').click(function () {
            if (this.checked)
              $("#ClaimsGrid tbody input:checkbox").attr("checked", this.checked);  //Magic line
            else {
              $("#ClaimsGrid tbody input:checkbox").removeAttr("checked", this.checked);  //Magic line
            }
          });
        });

Tags
Grid
Asked by
James
Top achievements
Rank 1
Answers by
James
Top achievements
Rank 1
Share this question
or