Hi
i'm new to SF and i cannot use a dropdown within a grid
I do not get how to use the @bind-Value="@((context as PaymentDetail).PaymentProject)">
If I use the commented line of code I can display the default value and the dropdown with my list but when I select it, it is not in the grid, the default value is still displayed. I can catch the new value in the OnChange though
Here is my code
<SfGrid @ref="paymentdetailsGrid"
TValue="PaymentDetail"
Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })"
Height="315"
DataSource="@paymentDetailList"
Query="@(new Syncfusion.Blazor.Data.Query().Where("PaymentId", "equal", SelectedPaymentId))"
>
<GridEditSettings AllowAdding="true"
AllowEditing="true"
AllowDeleting="true"
Mode="EditMode.Batch"
>
</GridEditSettings>
<GridEvents TValue="PaymentDetail"
OnBatchSave="OnBatchSavePaymentDetail"
>
</GridEvents>
<GridColumns>
<GridColumn Field=@nameof(PaymentDetail.PaymentDetailId) HeaderText="Id" Width="20" IsPrimaryKey="true" IsIdentity="true" />
<GridColumn Field=@nameof(PaymentDetail.PaymentProject) HeaderText="Project" EditType="EditType.DropDownEdit" Width="110">
<EditTemplate Context="pdp">
<SfDropDownList ID="PaymentProject" Placeholder="Select a project" TItem="Project" TValue="string"
DataSource="@projectList"
@bind-Value="@((context as PaymentDetail).PaymentProject)">
@*@bind-Value="@payment.PaymentDetails.Where(x => x.PaymentId == SelectedPaymentId).FirstOrDefault().PaymentProject"*@
<DropDownListEvents TItem="Project" TValue="string" ValueChange="ValueChange"></DropDownListEvents>
<DropDownListFieldSettings Text="ProjectName" Value="ProjectName"></DropDownListFieldSettings>
</SfDropDownList>
</EditTemplate>
</GridColumn>
<GridColumn Field=@nameof(PaymentDetail.Amount) HeaderText="Amount" Width="40" Type="ColumnType.Number" />
</GridColumns>
</SfGrid>
Upfront thanks
|
<GridForeignColumn Field=@nameof(Order.EmployeeID) HeaderText="Employee Name" ForeignKeyValue="FirstName" ForeignDataSource="@Employees" Width="150">
<EditTemplate>
<SfDropDownList ID="EmployeeID" @bind-Value="@((context as Order).EmployeeID)" TItem="EmployeeData" TValue="int?" DataSource="Employees">
<DropDownListFieldSettings Text="FirstName" Value="EmployeeID"></DropDownListFieldSettings>
</SfDropDownList>
</EditTemplate>
</GridForeignColumn> |