JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › Data Grid › Selection checkbox and height auto noisy effect. › Reply To: Selection checkbox and height auto noisy effect.
Hi,
The change event in Smart.Grid is triggered every time the selection changes, including when you click the same row twice.
So when you click the same row twice, it fires twice, but both have the same payload because the grid does not internally track a “previous state” for you.
` const data = [
{ Name: ‘John’, Age: 30 },
{ Name: ‘Alice’, Age: 25 },
{ Name: ‘Mark’, Age: 28 }
];
window.Smart(‘#grid’, class {
get properties() {
return {
selection: true,
dataSource: new Smart.DataAdapter({
dataSource: data,
dataFields: [
‘Name: string’,
‘Age: number’
]
}),
columns: [
{ label: ‘Name’, dataField: ‘Name’ },
{ label: ‘Age’, dataField: ‘Age’ }
]
};
}
});
const grid = document.querySelector(‘#grid’);
let previousSelection = [];
grid.addEventListener(‘change’, function (event) {
const currentSelection = grid.getSelection();
console.log(‘Previous:’, previousSelection);
console.log(‘Current:’, currentSelection);
// Compare changes
if (JSON.stringify(previousSelection) !== JSON.stringify(currentSelection)) {
console.log(‘Selection changed!’);
}
previousSelection = […currentSelection];
});`
Best Regards,
Markov
Smart UI Team
https://www.htmlelements.com/