|
<SfGrid @ref=@Table DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })">
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true"></GridEditSettings>
<GridEvents OnActionBegin="ActionBeginHandler" TValue="Order"></GridEvents>
<GridPageSettings PageSize=10 />
<GridColumns>
<EditTemplate>
<SfMultiSelect @ref="MultiSelect" ID="CustomerID" TValue="string[]" @bind-Value="@((context as Order).CustomerID)" Placeholder="e.g. Australia" DataSource="@Dropdown">
<MultiSelectFieldSettings Value="CustomerID" Text="CustomerID"></MultiSelectFieldSettings>
</SfMultiSelect>
</EditTemplate>
<Template>
@{
var d = (context as Order).CustomerID;
<span>@String.Join(",", d)</span> // for showing multi values in Grid column using Column template
}
</Template>
</GridColumn>
. . .
</GridColumns>
</SfGrid>
@code{
SfMultiSelect<string[]> MultiSelect;
public SfGrid<Order> Table { get; set; }
. . .
public void ActionBeginHandler(ActionEventArgs<Order> args)
{
if (args.RequestType == Syncfusion.Blazor.Grids.Action.Save)
{
args.Data.CustomerID = MultiSelect.Value; //Save the multiselect value in Grid datasource.
}
}
. . .
} |