I am getting grouped data in mvc grid(grouped on the basis of a column). I am trying to create a checkbox in the group header on clicking of which all the checkboxes within that group header gets selected.
@foreach(var group in Model.GroupBy(x=>x.Column)){
{
<tr class="group-header">
<td>
<input type="checkbox" id="checkAll"
onchange="toggleSelect(this.checked)">
</td>
<td colspan="6">
<span class="h3">@group.Key</span>
</td>
</tr>
foreach(var item in group)
{
<tr>
<td>
<input type="checkbox" class="checkGroup">
</td>
<td>
...
</td>
</tr>
}
jQuery for toggleSelect()
function toggleSelect()status{
$('.checkGroup').prop('checked',status);
}
When I use this all the checkboxes gets checked since all the checkboxes have same class(ckeckGroup). But I need only the checkboxes within a group to be checked. And the grouping to be used is dynamic so I cannot predefine any group. How can that be done?
Aucun commentaire:
Enregistrer un commentaire