In the attached project, there is a data grid with a column who's edit mode is "EditType.DropDownEdit":
<GridColumn Field=@nameof(Training.ProgramType)
HeaderText="Type"
EditType="EditType.DropDownEdit"
EditorSettings="@TrainingProgramTypeEditParams"
Width="150">
<EditTemplate>
<SfDropDownList @ref="DropDownList"
ID="ProgramType"
Placeholder="Program Type"
DataSource="@DropDown"
Value="@((context as Training).ProgramType.ToString())"
FloatLabelType="Syncfusion.Blazor.Inputs.FloatLabelType.Always"
TValue="string"
TItem="string">
</SfDropDownList >
</EditTemplate>
</GridColumn>
When I try to add or edit an item, I can open the drop down menu and select/change a new value for "ProgramType" and everything appears to be working correctly. As soon as I click on the SAVE button, the value of "Program Type" reverts back to "Training"
<SfGrid DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" })" Height="315">
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Dialog"></GridEditSettings>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" ValidationRules="@(new ValidationRules{ Required=true})" TextAlign="TextAlign.Right" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" ValidationRules="@(new ValidationRules{ Required=true})" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.ProgramType) HeaderText="Type" EditType="EditType.DropDownEdit" Width="150">
<EditTemplate>
<SfDropDownList ID="ProgramType" Placeholder="Program Type" DataSource="@DropDown" @bind-Value="@((context as Order).ProgramType)" FloatLabelType="Syncfusion.Blazor.Inputs.FloatLabelType.Always" AllowFiltering="true" TValue="ProgramType" TItem="string">
</SfDropDownList>
</EditTemplate>
</GridColumn>
<GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" EditType="EditType.DatePickerEdit" Format="d" TextAlign="TextAlign.Right" Width="130" Type="ColumnType.Date"></GridColumn>
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" EditType="EditType.NumericEdit" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.ShipCountry) HeaderText="Ship Country" EditType="EditType.DropDownEdit" Width="150"></GridColumn>
</GridColumns>
</SfGrid> |
That worked - thank you!
Hi,
Can you help me please extend the above example with the following functions:
Hi SZL,
Greetings from Syncfusion.
You can create the UrlAdaptor with our SfDataManager using the below documentation. Find the below link for your reference.
https://blazor.syncfusion.com/documentation/data/adaptors#url-adaptor
https://blazor.syncfusion.com/documentation/data/adaptors
https://forumassist.syncfusion.com/163946
For performing customized dialog editing, refer to the below documentation for your reference.
https://blazor.syncfusion.com/documentation/datagrid/template-editing#dialog-template
Normally if you render dropdown controls, it will fetch the data from your while clicking the dropdown icon. It will fetch and show the data while opening the dropdown popup.
If you want to show spinner while opening the dialog you can use ShowSpinnerAsync and HideSpinnerAsync methods of the Grid. Or you can use external spinner if you want. Refer the below API documentation for your reference
https://blazor.syncfusion.com/documentation/spinner/getting-started
If you want to perform validation using DataAnnotation, then you achieve your requirement by using the below way.
https://blazor.syncfusion.com/documentation/datagrid/data-annotation
Please let us know if you have any concerns.
Regards,
Rahul