Hi DevExpress!,
We tried to get the ColumnChooser of the Blazor-Grid to work with XAF.
We did the following:
C#public class BlazorGridFeaturesViewController : ViewController<ListView>
{
GridListEditor gridListEditor = null;
public BlazorGridFeaturesViewController()
{
}
protected override void OnActivated()
{
base.OnActivated();
gridListEditor = this.View.Editor as GridListEditor;
//...
}
protected override void OnDeactivated()
{
base.OnDeactivated();
}
protected override void OnViewControlsCreated()
{
base.OnViewControlsCreated();
//...
//Todo: if(View.Model.ShowColumnChooser)
EnableColumnChooser();
}
//...
protected void EnableColumnChooser()
{
var control = gridListEditor.Control as IDxDataGridAdapter;
control.DataGridModel.HeaderTemplate = builder =>
{
builder.OpenComponent<DevExpress.Blazor.DxToolbar>(1);
//"ChildContent" is a magic string here. m-(
//Or as the kids call it these days: this is by convention
//See https://docs.microsoft.com/en-us/aspnet/core/blazor/components/?view=aspnetcore-3.1#child-content
builder.AddAttribute(2, "ChildContent", (RenderFragment)((builder2) =>
{
builder2.OpenComponent<DevExpress.Blazor.DxDataGridColumnChooserToolbarItem>(3);
builder2.AddAttribute(0, "Alignment", DevExpress.Blazor.ToolbarItemAlignment.Left);
builder2.CloseComponent();
}));
builder.CloseComponent();
};
}
}
The Chooser is shown and works as expected.
BUT - after closing the app and restarting it, all settings are gone (obviously).
So my question is - how can I obtain the settings where the layout for the grid is stored so I can store it somewhere in the UserModel (e.g. through some ModelExtender)? And second: When is a good point in the page-lifecylce/view-lifecycle to save these settings and - more importantly - load them back?
Is this a valid approach anyway from your point of view? If not - what could be a valid approach?
Thanks a lot and best regards!