Hi,
I can not find any good way to mark only uniquely selected row in DataTable with a value and all other rows with other value.
For example let dt contains 3 rows and 2 columns (Option and Choice) - default for Choice is No:
Now user selects one row. Let it be first one:
then, user selects another row. Let it be second one:
My goal is to have unique selection among all rows, so when user selects first and then second, then first changes to No:
For the time being I couldn't find the way to know which row users clicked with on change event.
Dear @Marcin,
I don't quite get what you mean by selected - there are no selected rows in Data Table, unlike List or Library, where you can select a row. Do you mean which row is being edited at the moment?
Detect which row has changed.
And then change all others to default value - in this example it is 'No'.
I have prepared a solution for on change event:
window.helper = ''
///rest of code here
fd.control('dt').$on('change', function (modelobj) {
let tempHelper = helper
if (tempHelper == ''){
modelobj.forEach(element => {
if (element.Choice == 'YES'){
helpder = element.Option
}
})
} else {
modelobj.forEach(element =>{
if (element.Option == tempHelper){
element.Choice = 'NO'
} else if (element.Choice == 'YES' && element.Option != tempHelper) {
helper = element.Option
}
})
}
console.log(modelobj);
})
And I can see that values are correctly updated after each user action, but control doesn't show changes in browser.
Can't find refresh() or equivalent function for datatable.