Ejemplo n.º 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);
        }
Ejemplo n.º 2
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;
        }