Hi,
Please take a look of attached project. I am trying to use TValue="List<Countries>" instead of string[] but it is showing [object, object] as a selected value when you try to edit the row. Index.razor file
Hi Ponmani,
Thank you for the reply and providing the sample. I tried with the sample but when you edit row => change some selection in dropdown => click on update and then reclick on Edit it is not storing selected values to
public List<Countries> SelectedCountries { get; set; } of Order class. It is clearing out all the values.
can you please help for that?
Thanks & Regards
|
<GridEvents OnActionBegin="OnActionBegin" TValue="Order"></GridEvents>
<EditTemplate>
@{
var contextval = (context as Order);
_selectedLineIds = contextval.SelectedCountries;
}
<SfMultiSelect Value="@_selectedLineIds" TValue="List<Countries>" TItem="Countries" Placeholder="e.g. Australia" Mode="VisualMode.CheckBox" DataSource="@Country" ShowDropDownIcon="true">
<MultiSelectFieldSettings Value="Code" Text="Name"></MultiSelectFieldSettings>
<MultiSelectEvents OnValueRemove="OnValueRemove" OnValueSelect="OnValueSelect" TItem="Countries" TValue="List<Countries>"></MultiSelectEvents>
</SfMultiSelect>
</EditTemplate>
</GridColumn>
private List<Countries> _selectedLineIds = new List<Countries>();
public void OnValueSelect(SelectEventArgs<Countries> args)
{
//add the selected items from multiselect to custom List
_selectedLineIds.Add(args.ItemData);
}
public void OnValueRemove(RemoveEventArgs<Countries> args)
{
//remove the unselected items from multiselect to custom List
_selectedLineIds.Remove(args.ItemData);
}
public void OnActionBegin(ActionEventArgs<Order> args)
{
if (args.RequestType.Equals(Action.Save))
{
//assign the seelcted itesm from multiselect dropdown to args.Data
args.Data.SelectedCountries = _selectedLineIds;
}
} |
Hi Ponmani,
Thank you for the sample and reply. It worked for me.
Regards,
Rohan
Hi Rohan,
We are glad to hear that the issue has been resolved in your end. Please get back us if you need further assistance.
Regards,
Ponmani M