I am using Syncfusion Grid in a Blazor Core 3.1.0 App. I am binding data through a Web API. Now I want to show one of the columns/fields as a dropdown list in the grid.
By this URL:
Api/Default/GetProjectsList
I get the key and value pair that I need to bind to the drop-down list's text and value.
I have used the EjsDropDownList control and bound the data with the list. But how to make this list a column in the Grid is where I am struggling at. Because with Grid I use the CRUD functionality of the API. Tried enclosing the EjsDropDownList in a GridColumn tag but the list has not become a part of the Grid.
Please help.
<EjsGrid TValue="Order" AllowPaging="true" Toolbar="@(new List() { " Add", "Edit", "Delete", "Cancel", "Update" })">
<EjsDataManager Url="/Api/Orders" Adaptor="Adaptors.WebApiAdaptor">EjsDataManager>
<GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true" Mode="EditMode.Normal">GridEditSettings>
<GridColumns>
<GridColumn>
<EjsDropDownList TValue="string" Placeholder="Select a Project">
<EjsDataManager Url="/Api/Default/GetProjectsList" Adaptor="Adaptors.WebApiAdaptor" CrossDomain=true>EjsDataManager>
<DropDownListFieldSettings Text="Item1" Value="Item2">DropDownListFieldSettings>
EjsDropDownList>
GridColumn>
<GridColumn Field=@nameof(Order.OrderId) DefaultValue="0" IsIdentity="true" IsPrimaryKey="true" HeaderText="ID" TextAlign="TextAlign.Right">
GridColumn>
GridColumns>
EjsGrid>
Thanks in advance.
<EjsGrid TValue="Order" ModelType="@Model" AllowPaging="true" ...>
...
<GridColumns>
<GridColumn>
<Template>
<EjsDropDownList TValue="string" Placeholder="Select a Project">
<EjsDataManager Url="/Api/Default/GetProjectsList" Adaptor="Adaptors.WebApiAdaptor" CrossDomain=true></EjsDataManager>
<DropDownListFieldSettings Text="Item1" Value="Item2"></DropDownListFieldSettings>
</EjsDropDownList>
</Template>
</GridColumn>
...
</GridColumns>
</EjsGrid>
@code{
EjsButton accountButton;
public Order Model = new Order();
...
}
|
<EjsGrid DataSource="@Orders" ModelType="@Model" Toolbar=@ToolbarItems>
...
<GridColumns>
...
<GridColumn Field=@nameof(Order.EmployeeID) HeaderText="Employee Name" ForeignKeyValue="FirstName" DataSource="@Employees" Width="150">
<EditTemplate>
<EjsDropDownList TValue="string" ID="EmployeeID" Index="0" DataSource="@Employees">
<DropDownListFieldSettings Text="FirstName" Value="EmployeeID"></DropDownListFieldSettings>
</EjsDropDownList>
</EditTemplate>
</GridColumn>
...
</GridColumns>
</EjsGrid>
|
<EjsGrid DataSource="@Orders" ModelType="@Model" Toolbar=@ToolbarItems>
...
</EjsGrid>
@code{
...
public Order Model = new Order();
}
|