Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change how grids save state on navigation #842

Open
wants to merge 1 commit into
base: vnext
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions samples/grids/grid/state-persistence-main/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
};
private string stateKey = "grid-state";
private IgbIcon IconRef;
private IDisposable registration;

private CustomersData _customersData = null;
public CustomersData CustomersData
Expand All @@ -139,7 +140,6 @@

protected override void OnInitialized()
{
Navigation.LocationChanged += OnLocationChanged;
base.OnInitialized();
}

Expand All @@ -158,16 +158,21 @@
this.IconRef.RegisterIconFromText("refresh", refreshIcon, "material");
}));
}
if (firstRender)
{
registration = Navigation.RegisterLocationChangingHandler(OnLocationChanged);
}
}

void OnLocationChanged(object sender, LocationChangedEventArgs e)
ValueTask OnLocationChanged(LocationChangingContext arg)
{
SaveGridState();
return ValueTask.CompletedTask;
}

public void Dispose()
{
Navigation.LocationChanged -= OnLocationChanged;
registration?.Dispose();
}

void OnGridRendered()
Expand Down
12 changes: 9 additions & 3 deletions samples/grids/hierarchical-grid/state-persistence-main/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
};
private string stateKey = "hierarchical-grid-state";
private IgbIcon IconRef;
private IDisposable registration;

private SingersData _singersData = null;
public SingersData SingersData
Expand All @@ -164,7 +165,6 @@

protected override void OnInitialized()
{
Navigation.LocationChanged += OnLocationChanged;
base.OnInitialized();
}

Expand All @@ -183,16 +183,22 @@
this.IconRef.RegisterIconFromText("refresh", refreshIcon, "material");
}));
}

if (firstRender)
{
registration = Navigation.RegisterLocationChangingHandler(OnLocationChanged);
}
}

void OnLocationChanged(object sender, LocationChangedEventArgs e)
ValueTask OnLocationChanged(LocationChangingContext arg)
{
SaveGridState();
return ValueTask.CompletedTask;
}

public void Dispose()
{
Navigation.LocationChanged -= OnLocationChanged;
registration?.Dispose();
}

async void SaveGridState()
Expand Down
11 changes: 8 additions & 3 deletions samples/grids/pivot-grid/state-persistence-main/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
};
private string stateKey = "pivot-grid-state";
private IgbIcon IconRef;
private IDisposable registration;

private PivotDataFlat _pivotDataFlat = null;
public PivotDataFlat PivotDataFlat
Expand Down Expand Up @@ -194,7 +195,6 @@
}
protected override void OnInitialized()
{
Navigation.LocationChanged += OnLocationChanged;
base.OnInitialized();
}

Expand All @@ -213,16 +213,21 @@
this.IconRef.RegisterIconFromText("refresh", refreshIcon, "material");
}));
}
if (firstRender)
{
registration = Navigation.RegisterLocationChangingHandler(OnLocationChanged);
}
}

void OnLocationChanged(object sender, LocationChangedEventArgs e)
ValueTask OnLocationChanged(LocationChangingContext arg)
{
SaveGridState();
return ValueTask.CompletedTask;
}

public void Dispose()
{
Navigation.LocationChanged -= OnLocationChanged;
registration?.Dispose();
}

async void SaveGridState()
Expand Down
11 changes: 8 additions & 3 deletions samples/grids/tree-grid/state-persistence-main/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
};
private string stateKey = "tree-grid-state";
private IgbIcon IconRef;
private IDisposable registration;

private EmployeesNestedData _employeesData = null;
public EmployeesNestedData EmployeesData
Expand All @@ -160,7 +161,6 @@

protected override void OnInitialized()
{
Navigation.LocationChanged += OnLocationChanged;
base.OnInitialized();
}

Expand All @@ -179,16 +179,21 @@
this.IconRef.RegisterIconFromText("refresh", refreshIcon, "material");
}));
}
if (firstRender)
{
registration = Navigation.RegisterLocationChangingHandler(OnLocationChanged);
}
}

void OnLocationChanged(object sender, LocationChangedEventArgs e)
ValueTask OnLocationChanged(LocationChangingContext arg)
{
SaveGridState();
return ValueTask.CompletedTask;
}

public void Dispose()
{
Navigation.LocationChanged -= OnLocationChanged;
registration?.Dispose();
}

async void SaveGridState()
Expand Down