Posted 30 August 2018, 5:09 pm EST
Hi, again!
I have a page with a grid on the left and a bunch of check boxes on the right. The check box states change when the user selects an item from the grid on the left. If, however, the user changed the state of a checkbox before saving and they select an item from the grid, i want to prompt the user with a dialog that they will lose unsaved data if they contintue. The dialog is a wijmo-pop-up. I want to intercept the onSelectionChanged event on the grid so that if the user says ‘No’ in the dialog the selection doesn’t change and the check box states remain the same. But, if the user selects ‘Yes’ on the dialog, I want the selection on the grid to happen and the check box states to be refreshed.
I have everything working except the case where the user says ‘Yes.’ When the user clicks ‘Yes’ I return ‘true’ (not a string) to the onSelectionChanging eventhandler but the selection does not actually happen. It seems to behave as though I returned ‘false.’
Here’s the code:
...
locGridForSelectedUser = new wijmo.grid.FlexGrid('#permissionsLocationsGrid', {
itemsSource: $scope.selectedUserLocations,
autoGenerateColumns: true,
columns: [
{ binding: 'name', header: config.app.LOCALE.TEXT_NAME, width: '*', align: 'left' }
],
isReadOnly: true,
showAlternatingRows: true,
stickyHeaders: true,
selectionMode: 3,
autoSizeMode: 0,
allowDelete: true,
onSelectionChanging: function (e) { return checkDirty(e); },
onSelectionChanged: function () { locationGridForSelectedUserItemChanged() }
});
...
var checkDirty = function (cd) {
console.log('checkDirty()');
if (pageIsDirty == true) {
yesNoDlg.show(true, function (e) {
if (e.dialogResult == 'wj-hide-ok') {
console.log('return true');
return true;
} else {
console.log('return false');
return false;
}
});
}else{
console.log('return true');
return true;
}
}
I would expect that returning ‘true’ would allow the event chain to continue. Changing selections on the grid works fine if the page isn’t dirty. But when the dialog comes into play the behavior changes.
Thanks for your help!
Joe
