[Updated: made some correction.]

This commit is contained in:
Vivek 2021-10-14 19:20:55 +05:30
parent f25b5df002
commit b6bedb5d57
2 changed files with 28 additions and 10 deletions

View File

@ -8,7 +8,7 @@
$record_id = $record->{$index};
@endphp
<span class="checkbox">
<input type="checkbox" v-model="dataIds" @change="select($event)" value="{{ $record_id }}" :checked="dataGridIndexes.includes('{{ $record_id }}')">
<input type="checkbox" v-model="dataIds" @change="select($event)" value="{{ $record_id }}">
<label class="checkbox-view" for="checkbox"></label>
</span>

View File

@ -823,8 +823,13 @@
this.dataIds.pop(checkboxElement.value);
}
}
var routeArray = this.gridCurrentData.path.split('/');
var getLastRoute = routeArray[routeArray.length - 1];
localStorage.dataGridIndexes = JSON.stringify(this.dataIds);
var routeIndexObj = {};
routeIndexObj[getLastRoute] = this.dataIds;
localStorage.dataGridIndexes = JSON.stringify(routeIndexObj);
}
this.allSelected = false;
@ -840,9 +845,15 @@
* Triggered when page load.
*/
checkedSelectedCheckbox: function () {
var routeArray = this.gridCurrentData.path.split('/');
var getLastRoute = routeArray[routeArray.length - 1];
if ( typeof(Storage) !== 'undefined' ) {
var selectedIndexes = localStorage.getItem("dataGridIndexes");
this.dataIds = JSON.parse(selectedIndexes);
var selectedIndexes = JSON.parse(localStorage.getItem("dataGridIndexes"));
if ( Object.keys(selectedIndexes).length ) {
for (key in selectedIndexes) {
if ( key === getLastRoute) {
this.dataIds = selectedIndexes[key];
this.massActionsToggle = true;
this.allSelected = false;
@ -850,6 +861,13 @@
this.massActionsToggle = false;
this.massActionType = null;
}
} else {
delete selectedIndexes[key];
}
}
}
localStorage.dataGridIndexes = JSON.stringify(selectedIndexes);
}
},