PDA

View Full Version : How to generate ComboBox in Grid row cell with dynamic row data values in EXT.NET MVC?



rajeshb
Mar 24, 2017, 12:42 PM
Model format



public class JobCustomField{
public int CustomFieldTypeId { get; set; }
public string CustomFieldTypeValue { get; set; }
public string CustomFieldTypeName { get; set; }
public string FieldType { get; set; }
public string DefaultValue { get; set; }
public bool Required { get; set; }
public List<JobCustomFieldTypePickList> JobCustomFieldTypePickList { get; set; }
}

public class JobCustomFieldTypePickList
{

public string JobCustomFieldTypePickListName { get; set; }
public int DisplayOrder { get; set; }
}



Sample Data




List<JobCustomField> ModelData = new List<JobCustomField>(){
new JobCustomField(){
CustomFieldTypeId = 1,
CustomFieldTypeValue ="SA",
CustomFieldTypeName ="CFA",
FieldType="SINGLE",
DefaultValue="A",
JobCustomFieldTypePickList = new List<JobCustomFieldTypePickList>(){
new JobCustomFieldTypePickList(){
JobCustomFieldTypePickListName = "AA",
DisplayOrder = 1
}
}
},
new JobCustomField(){
CustomFieldTypeId = 2,
CustomFieldTypeValue ="SB",
CustomFieldTypeName ="CFB",
FieldType="MULTI",
DefaultValue="B",
JobCustomFieldTypePickList = new List<JobCustomFieldTypePickList>(){
new JobCustomFieldTypePickList(){
JobCustomFieldTypePickListName = "BA",
DisplayOrder = 1
},
new JobCustomFieldTypePickList(){
JobCustomFieldTypePickListName = "BB",
DisplayOrder = 1
},
new JobCustomFieldTypePickList(){
JobCustomFieldTypePickListName = "BC",
DisplayOrder = 1
}
}
}
};








@(
Html.X().GridPanel().Padding(5).Title("Custom Field(s)")
.ID("CustomFieldList")
.EmptyText("No Custom Field(s) found")
.AutoRender(false)
.Layout("fit")
.Height(530)
.Scroll(ScrollMode.None)
.Border(true)
.Store(Html.X().Store().ID("CustomFieldStore")
.Model(Html.X().Model().IDProperty("RowId")
.Fields(
new ModelField("FieldType") { Mapping = "FieldType" },
new ModelField("CustomFieldTypeName") { Mapping = "CustomFieldTypeName" },
new ModelField("CustomFieldTypeValue") { Mapping = "CustomFieldTypeValue" },
new ModelField("DefaultValue ") { Mapping = " DefaultValue " },
new ModelField("Required") { Mapping = "Required" },
new ModelField("JobCustomFieldTypePickList", ModelFieldType.Object) { IsComplex = true },
)
)
.DataSource(Model)
)
.ColumnModel(
column =>
{
column.Add(
Html.X().Column()
.Text("Custom Field")
.DataIndex("CustomFieldTypeName")
.Width(150));
column.Add(
Html.X().Column()
.Text("Field Type")
.DataIndex("FieldType")
.Width(150));
column.Add(
Html.X().ComponentColumn()
.Editor(true)
.ID("CustomFieldValue")
.DataIndex("JobCustomFieldTypePickList")
.Width(150)
.Text("Value")
.Component(
Html.X().Container()
.Items(
Html.X().ComboBox()
.ItemID("CustomFieldValueMultiDrop")
.ID("CustomFieldValueMultiDrop")
.Flex(1)
.QueryMode(DataLoadMode.Local)
.ValueField("JobCustomFieldTypePickListName")
.EmptyText("(All)")
.DisplayField("JobCustomFieldTypePickListName")
.Store(Html.X().Store().ID("PickListValuestore")
.AutoLoad(true)
.Model(Html.X().Model()
.IDProperty("JobCustomFieldTypePickListName")
.Fields(
new ModelField("JobCustomFieldTypePickListName", ModelFieldType.String) { Mapping = "JobCustomFieldTypePickListName" }
)
)
})







need to display Combo box in third column and fill comboBox items JobCustomFieldTypePickList

Result

We getting combobox in grid but combobox data not filled.

fabricio.murta
Mar 25, 2017, 3:55 PM
Hello @rajeshb! Welcome to Ext.NET Forums!

Would you mind wrapping your code in
tags so we and other community members can actually read and copy-paste your code in attempts to run and reproduce your scenario to advise you?..

It should look like something like this:



@(
Html.X().Panel()
.ID("myPanel")
)


Besides, I can't say if your code sample is runnable as it is now. So in advance, I suggest you reviewing our tips on posting threads so you can provide test cases everyone can run on their side and provide you best help with.

Here are useful threads with tips on doing so:
- Tips for creating simplified code samples (http://forums.ext.net/showthread.php?61176-Tips-for-creating-simplified-code-samples)
- More Information Required (http://forums.ext.net/showthread.php?10205-More-Information-Required)
- Forum Guidelines (http://forums.ext.net/showthread.php?3440-Forum-Guidelines-For-Posting-New-Topics)

Hope this helps!