Below is my code to add Add and Remove labels dynamically based on user selection setting the value works but i am unable to see Add and Remove labels with checkboxes. Can anyone let me know the solution
JavaScript
function dynamicBinding() {
var var= Ext.getCmp('students').query('[isCheckbox]');
var grid = Ext.getCmp('grdStudents');
grid.on('selectionchange', function () {
var Count = grid.getSelectionModel().getCount();
var totalCount = grid.getStore().getCount();
if (Count === totalCount) {
var.setText = 'Remove';
var.setValue = true;
} else {
var.setText = 'Add';
var.setValue = false;
}
});
}
Amit MohantyRank #112 · 20K reputationPosted May 23, 2023, 5:58 AM EDT
Try this
function dynamicBinding() { var checkboxes = Ext.getCmp('students').query('[isCheckbox]'); var grid = Ext.getCmp('grdStudents'); grid.on('selectionchange', function () { var count = grid.getSelectionModel().getCount(); var totalCount = grid.getStore().getCount(); var labelText = (count === totalCount) ? 'Remove' : 'Add'; var checkboxValue = (count === totalCount); checkboxes.forEach(function (checkbox) { checkbox.setText(labelText); checkbox.setValue(checkboxValue); }); }); }