Checkbox not set to selected when using the command parameter
Checkbox not set to selected when using the command parameter
Hi,
Am trying to adding a checkbox column to an exisitng datatable. has achieved the paging and the checkbox value retaining too when i navigate the pages. But the initial selected checkbox are not shown in UI on the first page which is loaded. When i come back navigate from second page to first page , the checkbox are showing as i have the logic for that in the ajax call. Please find the code below and let me know if you have any idea .
'''
'''
Checkbox selected change code below
'''
define(["commands/CommandBase"], function (CommandBase) {
function CheckboxCheckedChangedCommand(viewModel, dialogContainerId) {
self = viewModel;
CommandBase.call(this, viewModel);
}
var self = null;;
CheckboxCheckedChangedCommand.prototype = new CommandBase;
CheckboxCheckedChangedCommand.prototype.constructor = CheckboxCheckedChangedCommand;
CheckboxCheckedChangedCommand.prototype.execute = function (parameter) {
if (parameter != undefined || parameter != null) {
var workingItem = parameter.WorkingItem;
var selectedItems = parameter.SelectedItems();
var match = ko.utils.arrayFirst(selectedItems, function (i) {
if(i.Id != undefined)
return i.Id() === workingItem.Id();
else
return i.$id() === workingItem.$id();
});
if (workingItem.IsSelected()) {
if (!match) {
parameter.SelectedItems.push(workingItem);
parameter.WorkingItem.IsSelected(ko.observable(true));
}
}
else {
if (match) {
parameter.SelectedItems.remove(match);
}
}
}
};
return CheckboxCheckedChangedCommand;
});
'''
Thanks
vj