Opened

Best way to link a main view to a detail view

dhileaga commented

I have a grid, or a tree, as a main view which in on selection on an item on main view needs to refresh a detail view (either another grid or form). I tried the message service but I don't think I understood how it works. Your help is appreciated.

mladenmacanovic commented

To manually refresh DataGrid, you need to have assign it a ref attribute and then just call a Refresh method.

Example:

await dataGridRef.Refresh();.

or, to reload data

await dataGridRef.Reload();.

dhileaga commented

Thank you. What if the detail view is a form? I'm not sure I see in your examples something like Form

mladenmacanovic commented

I'm not sure if I understand the question. Can you please explain?

dhileaga commented

mladenmacanovic commented

The way to update your form is entirely upon to you. In most cases you only need to call StateHasChanged in the right place. We give you enough option to make it possible with the SelectedRow API.

Example:

<DataGrid SelectedRow="@selectedItem" SelectedRowChanged="@OnSelectedItemChanged">

@code{
  Task OnSelectedItemChanged(ItemModel item)
	{
	  selectedItem = item
		
		// call StateHasChanged here, but inside of the detail form
	
	  return Task.CompletedTask;
	}
}
Want to comment on this issue? Log in and write your comment.
Asignee
No assignee
Labels
No Labels