Blazor Grid Column Resize Event

1 Answer 58 Views
Grid
John
Top achievements
Rank 1
John asked on 18 Aug 2021, 09:34 PM

Hi,

My PM is wanting us to capture the column resize event and save this so when a user comes back to a certain page the column widths are set to the previous widths they set.

 

Is there a way to capture the a column resize width and the widths of the columns?

 

Thanks

1 Answer, 1 is accepted

Sort by
1
Accepted
Matthias
Top achievements
Rank 5
Bronze
Bronze
Iron
answered on 19 Aug 2021, 04:14 PM | edited on 19 Aug 2021, 04:16 PM

 

 

Hi John, there are several ways to do this.
The simplest way is GridState: documentation and an example

 

Alternatively, you can use the OnStateChanged event and save the column width:

State event

for example:

 OnStateChanged="@((GridStateEventArgs<dtoObj> args) => OnStateChangedHandler(args))"



void OnStateChangedHandler(GridStateEventArgs<dtoObj> args)
    {

          foreach (var item in args.GridState.ColumnStates)
            {
// Width
            }
   }

Tags
Grid
Asked by
John
Top achievements
Rank 1
Answers by
Matthias
Top achievements
Rank 5
Bronze
Bronze
Iron
Share this question
or