dataGrid.View

Hi
I have a datagrid without paging.

<RadzenDataGrid @ref=dataGrid Style="height: 420px" Data="@dzialList"

After adding the row, I reload the data and call the javascript, which sets the visibility of the highlighted row by reading its position in the list.
This works great for editing, but after adding a row and reloading the data, dataGrid.View.ToList() does not contain the new row yet. Despite the orders
await dataGrid.Reload();
StateHasChanged();
After the procedure is completed, the new row is visible in the grid, but scrolling did not work.


-> Adds row

 dynamic dialogResult =
         await DialogService.OpenAsync<DzialDialog>(editName, new Dictionary<string, object>() { { "id", 0 }, { "viewMode", false } },
         new DialogOptions() { Width = "700px", Height = "500", Resizable = false, Draggable = true });
 if (dialogResult != null)
 {  
dzial = (Dzial) dialogResult;
var query = planData.nxPlanowanieDataContext.Dzials.Where(x => x.IdDzial > 0).AsQueryable();
//...
dzialList = query.ToList();   
await dataGrid.Reload();
StateHasChanged();

//Now try find dzial in dzialList
int index = dataGrid.View.ToList().IndexOf(dzial);
//The new line is not in the list

Thans
Maciej

Better use some key property to find what you are looking for since IndexOf(), Contains(), etc. will unable to locate object in a list with different hash even if all property values are the same.

The problem is that there is no added row in the dataGrid.View list.
Datasource of DataGrid - dzialList has e.g. 20 elements including a new row, and dataGrid.View still has 19.

If it’s not part of the View the item is not part of the Data as well. You can check our code for reference.

The new row is in the list, but only when you return to view.

dzialList = query.ToList();   // is that enough?

// Here dziaList has 20 items

await dataGrid.Reload();
StateHasChanged();

//Here dataGrid.View has 19 items
int index = dataGrid.View.ToList().IndexOf(dzial);
//After return from procedure, the new row is visible

[/quote]

thanks
Maciej