如何在EXT.NET MVC中使用动态行数据值在Grid行单元格中生成ComboBox?

时间:2017-03-27 08:55:02

标签: c# asp.net-mvc razor combobox ext.net

如何在EXT.NET MVC中使用动态行数据值生成网格行单元格中的ComboBox?C?

模型格式

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; }
    }

示例数据

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
                                                            }
                                                        }
                                    }
            };

ViewPage代码

@(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" }
                                  )
                             )
                })

需要在第三列中显示组合框并填充comboBox项JobCustomFieldTypePickList

结果

我们在网格中获得了组合框,但组合框数据没有填充。

0 个答案:

没有答案