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

[Solved] Add check box in Header Row & CheckAll Options (ASP .NET MVC Telerik Grid)

1 Answer 140 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.
Mani
Top achievements
Rank 1
Mani asked on 11 Aug 2010, 06:58 AM
i want to add the checkbox in my ASP .NET MVC  Telerik Grid Header row.
and also, when i check the headerrow checkbox  and its need checked the all rows in Grid.

how to do this???

and also, i want to remove the Sorting and Filter Options in Particular Column in a Grid.

Thanks,
Manikandan.S

1 Answer, 1 is accepted

Sort by
0
larry
Top achievements
Rank 1
answered on 12 Nov 2010, 07:36 PM
// need to give your table an ID

....
.TableHtmlAttributes(new { id = "MyTable" })
columns.Template(o =>
                    {
                      %>
                        <input name="checkedGroups" type="checkbox" class="checkboxGroups"/>
                      <%
                    })
                    .Title("<input id='mastercheckbox' type='checkbox' />")   // add checkbox to header
                    .HeaderHtmlAttributes(new { style = "text-align:center;" })
                    .Width(50)
                    .HtmlAttributes(new { style = "text-align:center;" });


// And then some jquery:

<script type="text/javascript" language="javascript">
  $(document).ready(function () {

    // MasterCheckBox functionality
    $('#mastercheckbox').click(function () {
      if ($(this).attr('checked')) {
        $('.checkboxGroups').attr('checked', 'checked');
      } else {
        $('.checkboxGroups').removeAttr('checked');
      }
    });

    $('#MyTable input[type=checkbox][id!=mastercheckbox]').click(function () {
      var numChkBoxes = $('#MyTable input[type=checkbox][id!=mastercheckbox]').length;
      var numChkBoxesChecked = $('#MyTable input[type=checkbox][checked][id!=mastercheckbox]').length;
      if (numChkBoxes == numChkBoxesChecked && numChkBoxes > 0) {
        $('#mastercheckbox').attr('checked','checked');
      }
      else {
        $('#mastercheckbox').attr('checked', '');
      }
    });


  });
</script>
Tags
Grid
Asked by
Mani
Top achievements
Rank 1
Answers by
larry
Top achievements
Rank 1
Share this question
or