Below is my group click code when trying to select the group i am calling toggleGroupSelection and updateGroupCheckbox functions
function toggleGroupSelection(grid, groupId, checked) {
var sm = grid.getSelectionModel();
var store = grid.getStore();
// Check if the group exists
var group = store.getGroups().get(groupId);
if (group) {
var records = group.items;
var indexes = records.map(function (record) {
return store.indexOf(record);
});
if (checked) {
sm.selectRange(indexes[0], indexes[indexes.length - 1], true);
} else {
sm.deselect(indexes);
}
// Call updateGroupCheckbox after updating selection
updateGroupCheckbox(grid.getView(), groupId);
}
}
function updateGroupCheckbox(view, groupId) {
var sm = view.getSelectionModel();
var store = view.getStore();
var records = store.getGroups().get(groupId).items;
var allSelected = records.every(function (record) {
return sm.isSelected(record);
});
var checkbox = view.el.down('.x-grid-group-hd[data-groupname="' + groupId + '"] input[type=checkbox]');
if (allSelected) {
checkbox.dom.checked = true;
checkbox.up('div').down('span').update('Remove All');
} else {
checkbox.dom.checked = false;
checkbox.up('div').down('span').update('Add All');
}
}
actually this input type="checkbox" id="Primary-checkbox" should not have the expand and collapse behaviour but getting that behaviour.Below is the html code which i am trying to use to bind Add all in the group
avairPosted May 30, 2023, 7:08 PM
by making these changes also i still see it has expand and collapse behaviour more over with the previous code i used to face only one issue i.e Clicking on Add all all the child records were not selected vice versa i.e clicking on child records has allowed me to check Add All checkbox dynamically which is not working now
Rajkiran SwainPosted May 30, 2023, 6:30 PM
Based on the provided code snippets, it appears that you are using Ext.NET framework for building your web application. In order to modify the behavior of the checkbox in the group header, you can make the following changes:
1. Remove the event handling code that causes the expand/collapse behavior when the checkbox is clicked. In the `GroupClick` handler, remove the following lines:
This will allow the checkbox to be clicked without triggering the expand/collapse behavior.
2. Add an event listener to the checkbox to handle its click event separately. You can use the `addEventListener` method to bind a click event listener to the checkbox element. Modify the `updateGroupCheckbox` function to include the event listener code:
By adding this event listener, you can handle the checkbox click event separately and prevent its propagation, allowing you to perform custom actions without triggering the expand/collapse behavior.
With these changes, the checkbox in the group header should no longer exhibit the expand/collapse behavior when clicked.