|
<script>
var value = window.localStorage.getItem('gridGrid'); //"gridGrid" is component name + component id.
var model = JSON.parse(value);
delete model["columns"]; // remove the column from localStorage
window.localStorage.setItem('gridGrid', JSON.stringify(model));
</script>
<div>
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.dataSource).Columns(col =>
{
if (rndnumber % 2 ==0){
foreach (var i in new List<string>() {"OrderID", "CustomerID" }) {
col.Field(i).HeaderText(i).Add(); // add columns dynamically
}}
col.Field("Freight").HeaderText("Freight").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("120").Format("C2").Add();
col.Field("ShippedDate").HeaderText("Shipped Date").Width("140").Format("yMd").Add();
}).AllowPaging().EnablePersistence(true).PageSettings(page => page.PageSize(8)).Render()
</div> |
|
<script>
var value = window.localStorage.getItem('gridGrid');//"gridGrid" is component name + component id.
var model = JSON.parse(value);
delete model["columns"];
window.localStorage.setItem('gridGrid', JSON.stringify(model));
</script>
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.dataSource).Columns(col =>
{ col.Field("ShippedDate").HeaderText("Shipped Date").Width("140").Format("yMd").Add();
}).AllowPaging().EnablePersistence(true).PageSettings(page => page.PageSize(8)).Render() |
|
index.js
document.getElementById('Delete').onclick = () => {
grid.enablePersistence = false;
window.localStorage.setItem("Grid", "");
grid.destroy();
location.reload();
}
|