Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
IgGrid Check boxes not deselecting
posted

Hello, 

I'm having an issue with the check box function of the igGrid.

When deselecting the check box the row is staying selected.

i have tried the deselect method, but this also fails.

i get the following error in both scenarios "Uncaught TypeError: Cannot read property '0' of null "

I'm using the 2014 vesrion of the grid.

 jquery 1.9 and jquery ui 1.11.1.

this is my code

<script>
jQuery(function($) {
$('#grid1').igGrid({
dataSource: '@Url.Action("dataset-binding")',
autoGenerateColumns: false,
columns: [
{ hidden: true, key: "FirmIdString", template: "${FirmIdString}" },
{ hidden: false, key: "CanSelectForExtraction", template: "${CanSelectForExtraction}" },
{ headerText: "Firm Name", key: "FirmName", template: "${FirmName}", width: "65%" },
{ headerText: "Status", key: "StatusDescription", template: "${StatusDescription}", width: "15%" },
{ headerText: "Request Id", key: "StagingDatabaseId", template: "${StagingDatabaseId}", width: "15%" },
{ headerText: "Request", key: "RequestId", template: "${RequestId}", hidden: true }
],

autoGenerateLayouts: false,
mergeUnboundColumns: false,
responseDataKey: 'Records',
generateCompactJSONResponse: false,
enableUTCDates: true,
features: [
{ sortUrlKey: 'sort', sortUrlKeyAscValue: 'asc', sortUrlKeyDescValue: 'desc', name: 'Sorting', type: 'remote' },
{ recordCountKey: 'TotalRecordsCount', pageIndexUrlKey: 'page', pageSizeUrlKey: 'pageSize', name: 'Paging', pageSize: 25, type: 'remote' },
{ filterExprUrlKey: 'filter', filterLogicUrlKey: 'filterLogic', name: 'Filtering', type: 'remote' },
{ name: 'GroupBy', resultResponseKey: 'GroupBy', groupByUrlKey: 'sort', groupByUrlKeyAscValue: 'asc', groupByUrlKeyDescValue: 'desc', persist: false },
{
name: 'Selection', mode: "row", multipleSelection: true,
activation: false, rowSelectionChanging: function (evt, ui) {
return false;
}
},
{
name: 'RowSelectors',
enableCheckBoxes: true,
rowSelectorColumnWidth: '5%',
enableRowNumbering: false,
checkBoxStateChanging: function (evt, ui) {
var record = $("#grid1").igGrid("findRecordByKey", ui.rowKey);
if (ui.newState == 'off') {
var selectedRows = $("#grid1").igGridSelection("selectedRows");
$("#grid1").igGridSelection("deselectRow", 0);
// $("#grid1").igGridSelection("clearSelection");
}

if (record == null || (ui.newState == "on" && record.CanSelectForExtraction != true)) {

return false;
}

return true;

}

}
],
width: '100%',
primaryKey: 'FirmIdString',
localSchemaTransform: false,
cellClick: function(evt, ui) {
if (ui.colKey == "StagingDatabaseId") {

var dataBase = $("#grid1").igGrid("getCellText", ui.rowKey, "StagingDatabaseId");
if (!String.isNullOrEmpty(dataBase)) {
var record = $("#grid1").igGrid("findRecordByKey", ui.rowKey);
$(location).attr('href', '@Url.Action("Index", "RequestDetails")' + '/Index/' + record.RequestId.toString());
}
}
}
});
});

Thanks, Stephen