Product ID | Product Name | Unit Price | Units In Stock | Units On Order |
---|
@((context2 as Product).ProductID) | @((context2 as Product).Products) | @((context2 as Product).UnitPrice) | @((context2 as Product).UnitsInStock) | @((context2 as Product).UnitsOnOrder) |
public async Task onFiltering(FilteringEventArgs args)
{
args.PreventDefaultAction = true;
var pre = new WhereFilter();
var predicate = new List<WhereFilter>();
predicate.Add(new WhereFilter() { Condition = "or", Field = "Name", value = args.Text, Operator = "contains", IgnoreAccent = true,IgnoreCase=true });
predicate.Add(new WhereFilter() { Condition = "or", Field = "Job", value = args.Text, Operator = "contains", IgnoreAccent = true, IgnoreCase = true });
pre = WhereFilter.Or(predicate);
query = new Query().Where(pre);
await this.comboboxObj.Filter(Country, query);
}
|
Name | Position |
---|
@((context2 as Countries).Name) | @((context2 as Countries).Job) |
public async Task onFiltering(FilteringEventArgs args)
{
args.PreventDefaultAction = true;
var pre = new WhereFilter();
var predicate = new List<WhereFilter>();
predicate.Add(new WhereFilter() { Condition = "or", Field = "Name", value = args.Text, Operator = "contains", IgnoreAccent = true, IgnoreCase = true });
predicate.Add(new WhereFilter() { Condition = "or", Field = "Job", value = args.Text, Operator = "contains", IgnoreAccent = true, IgnoreCase = true });
pre = WhereFilter.Or(predicate);
query = args.Text == "" ? new Query() : new Query().Where(pre);
await this.comboboxObj.Filter(Country, query);
} |
<SfComboBox @ref="comboboxObj" id="Country" SortOrder="SortOrder.Descending" TValue="string" TItem="Countries" @bind-Value="@((context as Order).Country)" Placeholder="e.g. Australia" CssClass="e-multi-column" DataSource="@Country" AllowFiltering="true" Query="@query" PopupWidth="700px">
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
</SfComboBox> |
<SfComboBox @ref="comboboxObj" TValue="string" TItem="Countries" Placeholder="e.g. Australia" CssClass="e-multi-column" DataSource="@Country" @bind-Value="CountryValue" AllowFiltering="true" Query="@query">
<ComboBoxFieldSettings Text="Name" Value="Code"></ComboBoxFieldSettings>
<ComboBoxTemplates TItem="Countries">
<HeaderTemplate>
<table><tr><th class="e-text-center">Name</th><th width="240px">Position</th></tr></table>
</HeaderTemplate>
<ItemTemplate>
<table><tbody><tr><td class="e-text-center">@((context as Countries).Name)</td><td width="240px">@((context as Countries).Job)</td></tr> </tbody></table>
</ItemTemplate>
</ComboBoxTemplates>
<ComboBoxEvents TValue="string" OnOpen="onOpen" ValueChange="onValueChange" Filtering="onFiltering"></ComboBoxEvents>
</SfComboBox>
public void onValueChange(ChangeEventArgs<string> args)
{
filter();
}
public async Task onOpen(BeforeOpenEventArgs args)
{
filter();
}
public async Task filter()
{
if (CountryValue == null)
{
query = new Query();
}
await this.comboboxObj.Filter(Country, query);
} |
public void onValueChange(ChangeEventArgs<string> args)
{
CountryValue = comboboxObj.Value;
filter();
}
public async Task onOpen(BeforeOpenEventArgs args)
{
CountryValue = comboboxObj.Value;
filter();
}
|
Hello there,
i have a similar issue with combobox in an editable grid.
I have 2 classes: one for units and the other for relations to an item class
public class ItemUnitModel
{
public int Id { get; set; }
public virtual int ItemId { get; set; }
public virtual int? UnitId { get; set; }
public bool IsStandard { get; set; } = false;
}
public class UnitModel
{
public int Id { get; set; }
public string Description { get; set; }
}
I want to show a list of ItemUnitModels in a datagrid with UnitId as Combobox in editmode.
Based on your examples i create this:
<SfGrid DataSource="@ItemUnitModelList" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" })" AllowPaging="false" Width="500px">
<GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true"></GridEditSettings>
<GridColumns>
<GridColumn Field=@nameof(ItemUnitModel.Id) HeaderText="Id" IsPrimaryKey="true" ValidationRules="@(new ValidationRules{ Required=true, Number=true})" TextAlign="TextAlign.Right" Width="40"></GridColumn>
<GridColumn Field=@nameof(ItemUnitModel.UnitId) HeaderText="Unit" ValidationRules="@(new ValidationRules{ Required=true})" Width="150">
<EditTemplate>
<SfComboBox TValue="int?" TItem="UnitModel" @bind-Value="(context as ItemUnitModel).UnitId" DataSource="@UnitModelList">
<ComboBoxFieldSettings Text="Description" Value="Id"/>
</SfComboBox>
</EditTemplate>
</GridColumn>
<GridColumn Field=@nameof(ItemUnitModel.IsStandard) EditType="EditType.BooleanEdit" DisplayAsCheckBox="true" TextAlign="TextAlign.Right" Width="40"></GridColumn>
</GridColumns>
</SfGrid>
the Result is this
only in edit mode i see the related description based on unitId. in normal mode its just the id as number wich is not an option for me.
if i try the same code of combobox outside the data grid it works perfect. What do i miss?
Regards
Stefan
Hi Monisha,
thats exactly what i need. Great! And no need of additional combobox. like a charm.
Thanks for this hint.
Problem solved.
Regards
Stefan