New OrderIndex on Datagrid, use with Active Directory and cache

Hello!

Excited about the new feature with orderindex for datagrid! How would you suggest saving the state per user in an application using Active Directory, is there a smooth way too store the information in the local cache?

Cheers!

Hi @RIProG,

We don't have much experience with such setup and cannot provide any advice.

1 Like

Alright, I will post here when I find a solution in case it would benefit someone else looking for the same kind of solution :slight_smile:

Hello again enchev.
I think we are about to solve our issue, but we're struggling a bit as to how to use the expression in orderindex with an await. We want to write something like this:
${await this.GetFromLocalStorage("mainGrid_" + UserService.CurrentUser.DisplayName) != null ? await this.GetFromLocalStorage("mainGrid_" + UserService.CurrentUser.DisplayName).DataGridColumns.where(x => x.OrderIndex = 0) : 0 }

Any thoughts?

You should avoid using such complex expressions in properties. What you can do instead is initialize a dictionary (or other property) with all column indices and use it instead. You need to

columnIndices = await this.GetFromLocalStorage("mainGrid_" + UserService.CurrentUser.DisplayName).DataGridColumns
<RadzenDataGridColumn Property="FirstName" OrderIndex="@GetOrderIndex(columnIndices, "FirstName")" />
1 Like

Thank you korchev, we will try that approach instead. What would be a suitable place to populate columnIndices, the datagrids load event?

You can use either the LoadData event of the DataGrid or the Load event of the page. The latter is probably better as it will execute only once.