示例#1
0
        private GridConfig CreateGridConfig(WebEntityViewMeta evm)
        {
            GridConfig grid = new GridConfig();

            var isTree = evm.EntityMeta.IsTreeEntity;

            var showInWhere = this.Option.isLookup ? ShowInWhere.DropDown : ShowInWhere.List;

            //使用list里面的属性生成每一列
            foreach (WebEntityPropertyViewMeta property in evm.OrderedEntityProperties())
            {
                if (property.CanShowIn(showInWhere))
                {
                    bool canEdit = !this.Option.isReadonly && !evm.NotAllowEdit && !property.IsReadonly;

                    var column = new GridColumnConfig
                    {
                        header    = property.Label,
                        dataIndex = property.Name,
                        //flex = 1,
                    };

                    if (evm.LockedProperties.Contains(property))
                    {
                        column.locked = true;
                    }

                    //对于引用属性需要分开来特殊处理
                    if (!property.IsReference)
                    {
                        column.dataIndex = property.Name;

                        if (canEdit)
                        {
                            column.editor = ServerTypeHelper.GetTypeEditor(property);
                        }
                    }
                    else
                    {
                        column.dataIndex = EntityModelGenerator.LabeledRefProperty(property.Name);

                        if (canEdit)
                        {
                            column.editor = ServerTypeHelper.CreateComboList(property);
                        }
                    }

                    grid.columns.Add(column);
                }
            }

            if (isTree && grid.columns.Count > 0)
            {
                grid.columns[0].xtype = "treecolumn";
            }

            this.AddCommands(evm, grid.tbar);

            return(grid);
        }
示例#2
0
        private FormConfig CreateFormConfig(WebEntityViewMeta evm)
        {
            FormConfig form = new FormConfig();

            //使用list里面的属性生成每一列
            foreach (WebEntityPropertyViewMeta property in evm.OrderedEntityProperties())
            {
                if (property.CanShowIn(ShowInWhere.Detail))
                {
                    bool isReadonly = this.Option.isReadonly || property.IsReadonly || evm.NotAllowEdit;

                    FieldConfig field = null;

                    //对于引用属性需要分开来特殊处理
                    if (!property.IsReference)
                    {
                        field      = ServerTypeHelper.GetTypeEditor(property);
                        field.name = property.Name;
                    }
                    else
                    {
                        field      = ServerTypeHelper.CreateComboList(property);
                        field.name = EntityModelGenerator.LabeledRefProperty(property.Name);
                    }

                    field.fieldLabel = property.Label;
                    field.anchor     = "100%";
                    field.isReadonly = isReadonly;
                    if (property.VisibilityIndicator.IsDynamic)
                    {
                        field.visibilityIndicator = property.VisibilityIndicator.Property.Name;
                    }

                    form.items.Add(field);
                }
            }

            this.AddCommands(evm, form.tbar);

            return(form);
        }