Esempio n. 1
0
        public static ColumnDisplayModel CreateColumnDisplayModel(Mode mode, params Property[] p)
        {
            if (p == null)
            {
                throw new ArgumentNullException("p");
            }
            if (p.Length == 0)
            {
                throw new ArgumentOutOfRangeException("p", "At least one property is requiered");
            }

            var last = p.Last();

            var colMdl = new ColumnDisplayModel()
            {
                Header         = string.Join(", ", p.Select(i => i.GetLabel()).ToArray()),
                Name           = string.Join(".", p.Select(i => i.Name).ToArray()),
                Property       = last,
                Properties     = p,
                RequestedWidth = p.Last().GetDisplayWidth(),
            };

            switch (mode)
            {
            case Mode.ReadOnly:
                colMdl.ControlKind     = last.ValueModelDescriptor.GetDefaultGridCellDisplayKind();
                colMdl.GridPreEditKind = last.ValueModelDescriptor.GetDefaultGridCellDisplayKind();
                break;

            case Mode.Editable:
                colMdl.ControlKind     = last.ValueModelDescriptor.GetDefaultGridCellEditorKind();
                colMdl.GridPreEditKind = last.ValueModelDescriptor.GetDefaultGridCellPreEditorKind();
                break;
            }
            return(colMdl);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a ColumnDisplayModel for a zetbox object property or property path
        /// </summary>
        /// <param name="mode">Requested mode (readonly, editable)</param>
        /// <param name="p">list of properties to build column for</param>
        /// <returns>a ready configurated ColumnDisplayModel</returns>
        public static ColumnDisplayModel Create(GridDisplayConfiguration.Mode mode, params Property[] p)
        {
            if (p == null) throw new ArgumentNullException("p");
            if (p.Length == 0) throw new ArgumentOutOfRangeException("p", "At least one property is requiered");

            var last = p.Last();

            var colMdl = new ColumnDisplayModel()
            {
                Header = string.Join(", ", p.Select(i => i.GetLabel()).ToArray()),
                Path = string.Join(".", p.Select(i => i.Name).ToArray()),
                DynamicOrderByExpression = FormatDynamicOrderByExpression(p),
                Property = last,
                Properties = p,
                RequestedWidth = p.Last().GetDisplayWidth(),
                Type = ColumnType.PropertyModel
            };
            switch (mode)
            {
                case GridDisplayConfiguration.Mode.ReadOnly:
                    colMdl.ControlKind = last.ValueModelDescriptor.GetDefaultGridCellDisplayKind();
                    colMdl.GridPreEditKind = last.ValueModelDescriptor.GetDefaultGridCellDisplayKind();
                    break;
                case GridDisplayConfiguration.Mode.Editable:
                    colMdl.ControlKind = last.ValueModelDescriptor.GetDefaultGridCellEditorKind();
                    colMdl.GridPreEditKind = last.ValueModelDescriptor.GetDefaultGridCellPreEditorKind();
                    break;
            }
            return colMdl;
        }