Пример #1
0
 /// <summary>設定Grid-ComboBox  </summary>
 /// <param name="column"></param>
 /// <param name="valueField"></param>
 /// <param name="textField"></param>
 /// <param name="dataSource"></param>
 public static void SetComboBox(MVCxGridViewColumn column, string valueField, string textField, object dataSource)
 {
     column.EditorProperties().ComboBox(
         p =>
     {
         p.TextField  = textField;
         p.ValueField = valueField;
         p.DataSource = dataSource;
     });
 }
Пример #2
0
 /// <summary>設定Grid-Textbox</summary>
 /// <param name="i"></param>
 /// <param name="displayFormatString"></param>
 public static void SetTextBox(MVCxGridViewColumn column, string displayFormatString)
 {
     column.EditorProperties().TextBox(
         p =>
     {
         if (!string.IsNullOrWhiteSpace(displayFormatString))
         {
             p.DisplayFormatString = displayFormatString;
         }
     });
 }
Пример #3
0
        public static void Set(this MVCxGridViewColumn gcol, GridDisplayColumn columnInfo)
        {
            gcol.SetProperties(columnInfo);


            //Default Value will be used as EmptyLayoutItem
            switch (columnInfo.ColumnType)
            {
            case MVCxGridViewColumnType.TimeEdit:
                if (columnInfo.Width.HasValue)
                {
                    gcol.Width = (!columnInfo.IsWidthAndHeightInPercentage) ? columnInfo.Width.Value : Unit.Percentage(columnInfo.Width.Value);
                }

                gcol.EditorProperties().TimeEdit(s =>
                {
                    s.EditFormat = EditFormat.Custom;
                    if (!string.IsNullOrEmpty(columnInfo.DisplayFormat))
                    {
                        s.EditFormatString    = columnInfo.DisplayFormat;
                        s.DisplayFormatString = columnInfo.DisplayFormat;
                    }
                    s.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithTooltip;
                    s.ValidationSettings.Display          = Display.Dynamic;
                    s.ValidationSettings.SetFocusOnError  = true;
                    s.NullDisplayText = "";
                    //s.Height = (!columnInfo.IsWidthAndHeightInPercentage) ? columnInfo.EditLayoutHeight : Unit.Percentage(columnInfo.EditLayoutHeight);
                    if (columnInfo.EditLayoutWidth.HasValue)
                    {
                        s.Width = (!columnInfo.IsWidthAndHeightInPercentage) ? columnInfo.EditLayoutWidth.Value : Unit.Percentage(columnInfo.EditLayoutWidth.Value);
                    }
                });
                break;

            case MVCxGridViewColumnType.DateEdit:
                if (columnInfo.Width.HasValue)
                {
                    gcol.Width = (!columnInfo.IsWidthAndHeightInPercentage) ? columnInfo.Width.Value : Unit.Percentage(columnInfo.Width.Value);
                }

                gcol.EditorProperties().DateEdit(s =>
                {
                    s.ValidationSettings.ErrorDisplayMode = columnInfo.ErrorDisplayMode;
                    if (string.IsNullOrEmpty(columnInfo.DisplayFormat))
                    {
                        columnInfo.DisplayFormat = DefaultDateMask;
                    }

                    if (!string.IsNullOrEmpty(columnInfo.DisplayFormat))
                    {
                        var editFormatString    = UtilitySystem.Settings.ConfigSettings["DateFormat"];
                        var displayFormatString = UtilitySystem.Settings.ConfigSettings["DateFormat"];



                        if (columnInfo.DisplayFormat.ToLower().Contains("hh") || columnInfo.DisplayFormat.ToLower().Equals("f") ||
                            columnInfo.DisplayFormat.ToLower().Equals("r") || columnInfo.DisplayFormat.ToLower().Equals("s") ||
                            columnInfo.DisplayFormat.ToLower().Equals("u"))
                        {
                            editFormatString    = UtilitySystem.Settings.ConfigSettings["DateTimeFormat"];
                            displayFormatString = UtilitySystem.Settings.ConfigSettings["DateTimeFormat"];
                        }

                        s.EditFormatString    = editFormatString;
                        s.DisplayFormatString = displayFormatString;
                        s.EditFormat          = EditFormat.Custom;
                        s.TimeSectionProperties.ShowSecondHand = false;
                        s.TimeSectionProperties.Visible        = true;
                    }

                    s.ValidationSettings.Display         = Display.Dynamic;
                    s.ValidationSettings.SetFocusOnError = true;
                    s.NullDisplayText = "";
                    //s.Height = (!columnInfo.IsWidthAndHeightInPercentage) ? columnInfo.EditLayoutHeight : Unit.Percentage(columnInfo.EditLayoutHeight);
                    if (columnInfo.EditLayoutWidth.HasValue)
                    {
                        s.Width = (!columnInfo.IsWidthAndHeightInPercentage) ? columnInfo.EditLayoutWidth.Value : Unit.Percentage(columnInfo.EditLayoutWidth.Value);
                    }
                });
                break;

            case MVCxGridViewColumnType.SpinEdit:
                if (columnInfo.Width.HasValue)
                {
                    gcol.Width = (!columnInfo.IsWidthAndHeightInPercentage) ? columnInfo.Width.Value : Unit.Percentage(columnInfo.Width.Value);
                }


                gcol.EditorProperties().SpinEdit(s =>
                {
                    if (columnInfo.EditorProperties != null)
                    {
                        try
                        {
                            s.NumberType = columnInfo.EditorProperties.NumberType;
                        }
                        catch (System.Exception)
                        {
                            ;
                        }
                    }
                    s.MinValue = 0;
                    s.MaxValue = Int32.MaxValue;
                    s.ValidationSettings.ErrorDisplayMode = columnInfo.ErrorDisplayMode;
                    s.ValidationSettings.Display          = Display.Dynamic;
                    s.ValidationSettings.SetFocusOnError  = true;
                    //s.Height = (!columnInfo.IsWidthAndHeightInPercentage) ? columnInfo.EditLayoutHeight : Unit.Percentage(columnInfo.EditLayoutHeight);
                    if (columnInfo.EditLayoutWidth.HasValue)
                    {
                        s.Width = (!columnInfo.IsWidthAndHeightInPercentage) ? columnInfo.EditLayoutWidth.Value : Unit.Percentage(columnInfo.EditLayoutWidth.Value);
                    }
                });
                break;

            case MVCxGridViewColumnType.CheckBox:
                if (columnInfo.Width.HasValue)
                {
                    gcol.Width = (!columnInfo.IsWidthAndHeightInPercentage) ? columnInfo.Width.Value : Unit.Percentage(columnInfo.Width.Value);
                }
                gcol.EditorProperties().CheckBox(s =>
                {
                    s.ValidationSettings.ErrorDisplayMode         = ErrorDisplayMode.ImageWithTooltip;
                    s.ValidationSettings.Display                  = Display.Dynamic;
                    s.ValidationSettings.SetFocusOnError          = true;
                    s.ValidationSettings.RequiredField.IsRequired = false;
                });
                break;

            case MVCxGridViewColumnType.BinaryImage:
                if (columnInfo.Width.HasValue)
                {
                    gcol.Width = (!columnInfo.IsWidthAndHeightInPercentage) ? columnInfo.Width.Value : Unit.Percentage(columnInfo.Width.Value);
                }

                gcol.EditorProperties().BinaryImage(p =>
                {
                    if (columnInfo.EditLayoutHeight.HasValue)
                    {
                        p.ImageHeight = (!columnInfo.IsWidthAndHeightInPercentage) ? columnInfo.EditLayoutHeight.Value : Unit.Percentage(columnInfo.EditLayoutHeight.Value);
                    }

                    if (columnInfo.EditLayoutWidth.HasValue)
                    {
                        p.ImageWidth = (!columnInfo.IsWidthAndHeightInPercentage) ? columnInfo.EditLayoutWidth.Value : Unit.Percentage(columnInfo.EditLayoutWidth.Value);
                    }
                    p.EnableServerResize      = true;
                    p.ImageSizeMode           = ImageSizeMode.FitProportional;
                    p.CallbackRouteValues     = columnInfo.CallBackRoute;
                    p.EditingSettings.Enabled = true;
                    p.EditingSettings.UploadSettings.UploadValidationSettings.MaxFileSize = 4194304;
                });
                break;

            case MVCxGridViewColumnType.ComboBox:
                if (columnInfo.Lookup != null && !columnInfo.IsGridLookup)
                {
                    if (columnInfo.Width.HasValue)
                    {
                        gcol.Width = (!columnInfo.IsWidthAndHeightInPercentage) ? columnInfo.Width.Value : Unit.Percentage(columnInfo.Width.Value);
                    }

                    gcol.EditorProperties().ComboBox(cb =>
                    {
                        cb.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithTooltip;
                        cb.ValidationSettings.Display          = Display.Dynamic;
                        cb.ValidationSettings.SetFocusOnError  = true;
                        cb.Width         = Unit.Percentage(100);
                        cb.NullText      = columnInfo.Lookup.NullCaption;
                        cb.TextField     = columnInfo.Lookup.DisplayColumnName;
                        cb.ValueField    = columnInfo.Lookup.KeyColumnName;
                        cb.DropDownStyle = columnInfo.Lookup.Style;
                        cb.DataSource    = columnInfo.Lookup.DataSource;
                        if (columnInfo.Lookup.CallbackRouteValues != null)
                        {
                            cb.CallbackRouteValues = columnInfo.Lookup.CallbackRouteValues;
                        }
                        if (!string.IsNullOrEmpty(columnInfo.Lookup.BeginCallBackEvent))
                        {
                            cb.ClientSideEvents.BeginCallback = columnInfo.Lookup.BeginCallBackEvent;
                        }
                        if (!string.IsNullOrEmpty(columnInfo.Lookup.SelectedIndexChangedEvent))
                        {
                            cb.ClientSideEvents.SelectedIndexChanged = columnInfo.Lookup.SelectedIndexChangedEvent;
                        }

                        //cb.Height = (!columnInfo.IsWidthAndHeightInPercentage) ? columnInfo.EditLayoutHeight : Unit.Percentage(columnInfo.EditLayoutHeight);
                        if (columnInfo.EditLayoutWidth.HasValue)
                        {
                            cb.Width = (!columnInfo.IsWidthAndHeightInPercentage) ? columnInfo.EditLayoutWidth.Value : Unit.Percentage(columnInfo.EditLayoutWidth.Value);
                        }
                    });
                }
                else     //gridView Lookup
                {
                }
                break;

            case MVCxGridViewColumnType.TextBox:
                if (columnInfo.Width.HasValue)
                {
                    gcol.Width = (!columnInfo.IsWidthAndHeightInPercentage) ? columnInfo.Width.Value : Unit.Percentage(columnInfo.Width.Value);
                }

                gcol.EditorProperties().TextBox(s =>
                {
                    s.EncodeHtml = columnInfo.EncodeHtml;
                    s.ValidationSettings.ErrorDisplayMode = columnInfo.ErrorDisplayMode;
                    s.ValidationSettings.Display          = Display.Dynamic;
                    s.ValidationSettings.SetFocusOnError  = true;
                    //s.Height = (!columnInfo.IsWidthAndHeightInPercentage) ? columnInfo.EditLayoutHeight : Unit.Percentage(columnInfo.EditLayoutHeight);
                    if (columnInfo.EditLayoutWidth.HasValue)
                    {
                        s.Width = (!columnInfo.IsWidthAndHeightInPercentage) ? columnInfo.EditLayoutWidth.Value : Unit.Percentage(columnInfo.EditLayoutWidth.Value);
                    }

                    if (columnInfo.DisplayFormat != null && columnInfo.DisplayFormat.Length > 0)
                    {
                        s.MaskSettings.Mask            = columnInfo.DisplayFormat;
                        s.MaskSettings.IncludeLiterals = MaskIncludeLiteralsMode.None;
                        s.DisplayFormatString          = columnInfo.DisplayFormat;
                    }
                });
                break;

            case MVCxGridViewColumnType.Memo:
                if (columnInfo.Width.HasValue)
                {
                    gcol.Width = (!columnInfo.IsWidthAndHeightInPercentage) ? columnInfo.Width.Value : Unit.Percentage(columnInfo.Width.Value);
                }
                gcol.EditorProperties().Memo(s =>
                {
                    s.EncodeHtml = columnInfo.EncodeHtml;
                    s.ValidationSettings.ErrorDisplayMode = columnInfo.ErrorDisplayMode;
                    s.ValidationSettings.Display          = Display.Dynamic;
                    s.ValidationSettings.SetFocusOnError  = true;
                    if (columnInfo.EditLayoutWidth.HasValue)
                    {
                        s.Width = (!columnInfo.IsWidthAndHeightInPercentage) ? columnInfo.EditLayoutWidth.Value : Unit.Percentage(columnInfo.EditLayoutWidth.Value);
                    }
                    if (columnInfo.EditLayoutHeight.HasValue)
                    {
                        s.Height = (!columnInfo.IsWidthAndHeightInPercentage) ? columnInfo.EditLayoutHeight.Value : Unit.Percentage(columnInfo.EditLayoutHeight.Value);
                    }
                });
                break;
            }

            if (!columnInfo.IsVisible)
            {
                gcol.Width = 0;
            }
        }