Hi
@{
var Tool = (new List<string>() { "Add", "Edit", "Delete", "Search" });
}
SfGrid DataSource="@Orders" EnableAdaptiveUI="true" AllowFiltering="true" AllowPaging="true" AllowSorting="true" Toolbar=@Tool>
<GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Menu"></GridFilterSettings>
<GridEditSettings AllowAdding="false" AllowDeleting="false" AllowEditing="false" Mode="EditMode.Dialog" ></GridEditSettings>
</SfGrid>
How do I get the item selected and instead show modal, inline edit etc.. I can redirect it to another page?
Hi Douglas,
Greetings from Syncfusion.
We have validated your query and we suspect that you want to add/edit the record on another page while clicking Add/Edit buttons in the toolbar. Here, we have prepared a sample based on your requirement. We have rendered an EditForm in another page for Edit and Add operation. While clicking Add, Edit button in the toolbar, it will navigate to Add, Edit page using the corresponding URL. You can perform your add, and edit operation on that page.
Find the below code snippets and sample for your reference. Here, we have navigated to the corresponding add/edit page while clicking the toolbar items Add/Edit.
|
<SfGrid DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Edit" })"> <GridEvents RowSelected="RowSelectedHandler" OnToolbarClick="ToolClick" TValue="Order"></GridEvents> <GridEditSettings AllowEditing="true" AllowAdding="true" AllowEditOnDblClick="false" AllowDeleting="true"></GridEditSettings> <GridColumns> . . . </GridColumns> </SfGrid>
@code{ public List<Order> Orders { get; set; } public Order SelectedRecord { get; set; } = new Order(); public void ToolClick(Syncfusion.Blazor.Navigations.ClickEventArgs Args) { if (Args.Item.Text == "Add") { NavigationManager.NavigateTo("addRecord/0"); } else if (Args.Item.Text == "Edit") { NavigationManager.NavigateTo($"editRecord/{SelectedRecord.OrderID}"); } } public void RowSelectedHandler(RowSelectEventArgs<Order> Args) { SelectedRecord.OrderID = Args.Data.OrderID; } protected override void OnInitialized() { Orders = Ord.GetOrderDetails(); }
. . . } |
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/SampleGrid134414674
Please let us know if you have any concerns.
Regards,
Rahul
Hi, Thanks soooo much, that was what I was looking for!
Is that possible to trigger Edit
AllowEditOnDblClick="true" and call
ToolClick instead of enabling edit in the row?
Hi Douglas,
Thanks for the update. We are happy to hear that the provided solution was helpful.
We suspect that you want to navigate to EditPage while double-clicking the record. If you want to navigate to the corresponding edit page while double-clicking the row, then you can achieve this by using the OnRecordDoubleClick event of the Grid.
https://blazor.syncfusion.com/documentation/datagrid/events#onrecorddoubleclick
|
<SfGrid DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Edit" })"> <GridEvents RowSelected="RowSelectedHandler" OnRecordDoubleClick="RecordDoubleClickHandler" OnToolbarClick="ToolClick" TValue="Order"></GridEvents> <GridEditSettings AllowEditing="true" AllowAdding="true" AllowEditOnDblClick="false" AllowDeleting="true"></GridEditSettings> <GridColumns> . .. </GridColumns> </SfGrid>
public void RecordDoubleClickHandler(RecordDoubleClickEventArgs<Order> Args) { SelectedRecord.OrderID = Args.RowData.OrderID; NavigationManager.NavigateTo($"editRecord/{SelectedRecord.OrderID}"); }
|
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/SampleDbl1337703485
Please let us know if you have any concerns.
Regards,
Rahul
After that, I cant wait to grow to start paying for the license! thanks, guys once more! I will spend more time reading the documentation next time!
Hi Douglas,
Thanks for the update.
Please get back to us if you need further assistance.
Regards,
Rahul