Jul 02, 2015, 5:23 AM
Binding ComboBox in Grid to the record's list in the same row
I am trying to bind the ComboBox to the record's SupportedOperators (which is a list of strings) in the same row. Each record might have a different list.
Model
I want the first ComboBox to display like the following:
Thanks!
Model
public class ConditionViewModel
{
public string Parameter;
public string Operator;
public IList<string> SupportedOperators;
public string Value;
}
Controller public ActionResult DisplayQuery()
{
List<ConditionViewModel> conditionList = new List<ConditionViewModel>();
conditionList.Add(new ConditionViewModel() { Parameter = "NAME", Operator = "=", SupportedOperators = new List<string>() { "!=", "=", "IS NULL", "IS NOT NULL" }, Value = "TEST NAME" });
conditionList.Add(new ConditionViewModel() { Parameter = "POSITION", Operator = "!=", SupportedOperators = new List<string>() { "!=", "=", "IS NULL", "IS NOT NULL" }, Value = "" });
conditionList.Add(new ConditionViewModel() { Parameter = "SALARY", Operator = ">=", SupportedOperators = new List<string>() { ">", "<", ">=", "<=" }, Value = "0" });
ViewBag.QueryConditionList = conditionList;
return View();
}
View@(
Html.X().Model()
.Name("QueryConditionModel")
.Fields(
Html.X().ModelField().Name("Parameter"),
Html.X().ModelField().Name("Operator"),
Html.X().ModelField().Name("Value"),
Html.X().ModelField().Name("SupportedOperators")
)
)
@(
Html.X().Store()
.ID("QueryConditionStore")
.Data(ViewBag.QueryConditionList)
.ModelName("QueryConditionModel")
)
@(
Html.X().GridPanel()
.Height(300)
.StoreID("QueryConditionStore")
.ColumnModel(
Html.X().Column().DataIndex("Parameter").Text("Parameter").Width(150)
.Editor(Html.X().TextField()),
Html.X().Column().DataIndex("Operator").Text("Operator").Width(80)
.Editor(
Html.X().ComboBox()
.QueryMode(DataLoadMode.Local)
.StoreID("QueryConditionStore")
.DisplayField("SupportedOperators")
.ValueField("SupportedOperators")
),
Html.X().Column().DataIndex("Value").Text("Value").Flex(1)
.Editor(Html.X().TextField())
)
.SelectionModel(Html.X().CellSelectionModel())
.Plugins(
Html.X().CellEditing()
)
)
I tried the above and it concatenates the list to a string and displays 3 records in each ComboBox. See the below screenshot.I want the first ComboBox to display like the following:
!=
=
IS NULL
IS NOT NULL
the third ComboBox to display like the following: >
<
>=
<=
Any help is appreciated.Thanks!