Im与Syncfusion Blazor部件合作,Im 有一些问题可以挽救模型,例如:
...
<GridColumns>
...
<GridColumn Field=@nameof(Project.ProgrammingLanguages) HeaderText="Programming Languages">
<Template>
@string.Join(",", (context as IEnumerable<ProgrammingLanguage>)?.Select(pl => pl.Name) ?? Enumerable.Empty<string>())
</Template>
<EditTemplate>
@{
Project project = context as Project ?? new();
project.ProgrammingLanguages = project.ProgrammingLanguages ?? Enumerable.Empty<ProgrammingLanguage>();
void HandleLanguageSelection(MultiSelectChangeEventArgs<ProgrammingLanguage[]> selectedValues)
{
if (selectedValues is not null)
project.ProgrammingLanguages = selectedValues.Value;
}
}
<SfMultiSelect TValue="ProgrammingLanguage[]" TItem="ProgrammingLanguage" Placeholder="Select a language" DataSource="@allLanguages">
<MultiSelectEvents TValue="ProgrammingLanguage[]" TItem="ProgrammingLanguage" ValueChange="@HandleLanguageSelection" />
<MultiSelectFieldSettings Text="@nameof(ProgrammingLanguage.Name)" />
</SfMultiSelect>
</EditTemplate>
</GridColumn>
</GridColumns>
...
After selecting some languages, "edit mode" closes on its own without saving models I also tried to implement it this way:
<SfMultiSelect TValue="IEnumerable<ProgrammingLanguage>" TItem="ProgrammingLanguage" Placeholder="Select a language" DataSource="@allLanguages" @bind-Value="project.ProgrammingLanguages">
<MultiSelectFieldSettings Text="@nameof(ProgrammingLanguage.Name)"/>
</SfMultiSelect>
我应该做些什么? 我试图利用其他活动来挽救模式,并且没有工作。