Beispiel #1
0
        private void ApplyFormatterOptions(JQGridColumn column)
        {
            Hashtable hashtable = new Hashtable();

            if (column.EditActionIconsColumn)
            {
                hashtable["keys"]       = column.EditActionIconsSettings.SaveOnEnterKeyPress;
                hashtable["editbutton"] = column.EditActionIconsSettings.ShowEditIcon;
                if (column.EditActionIconsSettings.ShowEditIcon && !string.IsNullOrEmpty(column.EditActionIconsSettings.onEdit))
                {
                    hashtable["onEdit"] = column.EditActionIconsSettings.onEdit;;
                    //editOptions : {}
                }
                hashtable["delbutton"] = column.EditActionIconsSettings.ShowDeleteIcon;
                if (column.EditActionIconsSettings.ShowDeleteIcon)
                {
                    Hashtable ht2 = new Hashtable();
                    if (!string.IsNullOrEmpty(column.EditActionIconsSettings.DelErrorTextFormat))
                    {
                        ht2["errorTextFormat"] = column.EditActionIconsSettings.DelErrorTextFormat;
                    }
                    if (!string.IsNullOrEmpty(_grid.ClientSideEvents.SerializeDelData))
                    {
                        ht2["serializeDelData"] = _grid.ClientSideEvents.SerializeDelData;
                    }
                    if (ht2.Count > 0)
                    {
                        hashtable["delOptions"] = ht2;
                    }
                }
            }
            if (column.Formatter != null)
            {
                JQGridColumnFormatter formatter = column.Formatter;
                if (formatter is LinkFormatter)
                {
                    LinkFormatter linkFormatter = (LinkFormatter)formatter;
                    this._jsonValues["formatter"] = "link";
                    if (!string.IsNullOrEmpty(linkFormatter.Target))
                    {
                        hashtable["target"] = linkFormatter.Target;
                    }
                }
                if (formatter is EmailFormatter)
                {
                    this._jsonValues["formatter"] = "email";
                }
                if (formatter is IntegerFormatter)
                {
                    IntegerFormatter integerFormatter = (IntegerFormatter)formatter;
                    this._jsonValues["formatter"] = "integer";
                    if (!string.IsNullOrEmpty(integerFormatter.ThousandsSeparator))
                    {
                        hashtable["thousandsSeparator"] = integerFormatter.ThousandsSeparator;
                    }
                    if (!string.IsNullOrEmpty(integerFormatter.DefaultValue))
                    {
                        hashtable["defaultValue"] = integerFormatter.DefaultValue;
                    }
                }
                if (formatter is NumberFormatter)
                {
                    NumberFormatter numberFormatter = (NumberFormatter)formatter;
                    this._jsonValues["formatter"] = "integer";
                    if (!string.IsNullOrEmpty(numberFormatter.ThousandsSeparator))
                    {
                        hashtable["thousandsSeparator"] = numberFormatter.ThousandsSeparator;
                    }
                    if (!string.IsNullOrEmpty(numberFormatter.DefaultValue))
                    {
                        hashtable["defaultValue"] = numberFormatter.DefaultValue;
                    }
                    if (!string.IsNullOrEmpty(numberFormatter.DecimalSeparator))
                    {
                        hashtable["decimalSeparator"] = numberFormatter.DecimalSeparator;
                    }
                    if (numberFormatter.DecimalPlaces != -1)
                    {
                        hashtable["decimalPlaces"] = numberFormatter.DecimalPlaces;
                    }
                }
                if (formatter is CurrencyFormatter)
                {
                    CurrencyFormatter currencyFormatter = (CurrencyFormatter)formatter;
                    this._jsonValues["formatter"] = "currency";
                    if (!string.IsNullOrEmpty(currencyFormatter.ThousandsSeparator))
                    {
                        hashtable["thousandsSeparator"] = currencyFormatter.ThousandsSeparator;
                    }
                    if (!string.IsNullOrEmpty(currencyFormatter.DefaultValue))
                    {
                        hashtable["defaultValue"] = currencyFormatter.DefaultValue;
                    }
                    if (!string.IsNullOrEmpty(currencyFormatter.DecimalSeparator))
                    {
                        hashtable["decimalSeparator"] = currencyFormatter.DecimalSeparator;
                    }
                    if (currencyFormatter.DecimalPlaces != -1)
                    {
                        hashtable["decimalPlaces"] = currencyFormatter.DecimalPlaces;
                    }
                    if (!string.IsNullOrEmpty(currencyFormatter.Prefix))
                    {
                        hashtable["prefix"] = currencyFormatter.Prefix;
                    }
                    if (!string.IsNullOrEmpty(currencyFormatter.Prefix))
                    {
                        hashtable["suffix"] = currencyFormatter.Suffix;
                    }
                }
                if (formatter is CheckBoxFormatter)
                {
                    CheckBoxFormatter checkBoxFormatter = (CheckBoxFormatter)formatter;
                    this._jsonValues["formatter"] = "checkbox";
                    if (checkBoxFormatter.Enabled)
                    {
                        hashtable["disabled"] = false;
                    }
                }
                if (formatter is DropDownFormatter)
                {
                    this._jsonValues["formatter"] = "select";
                }
                if (formatter is CustomFormatter)
                {
                    CustomFormatter customFormatter = (CustomFormatter)formatter;
                    if (!string.IsNullOrEmpty(customFormatter.FormatFunction))
                    {
                        this._jsonValues["formatter"] = customFormatter.FormatFunction;
                    }
                    if (!string.IsNullOrEmpty(customFormatter.UnFormatFunction))
                    {
                        this._jsonValues["unformat"] = customFormatter.UnFormatFunction;
                    }
                }
            }
            if (hashtable.Count > 0)
            {
                this._jsonValues["formatoptions"] = hashtable;
            }
        }
Beispiel #2
0
        private void ApplyFormatterOptions(JQGridColumn column)
        {
            Hashtable hashtable = new Hashtable();

            if (column.EditActionIconsColumn)
            {
                hashtable["keys"]       = column.EditActionIconsSettings.SaveOnEnterKeyPress;
                hashtable["editbutton"] = column.EditActionIconsSettings.ShowEditIcon;
                hashtable["delbutton"]  = column.EditActionIconsSettings.ShowDeleteIcon;
            }
            if (column.Formatter != null)
            {
                JQGridColumnFormatter formatter = column.Formatter;
                if (formatter is LinkFormatter)
                {
                    LinkFormatter formatter2 = (LinkFormatter)formatter;
                    this._jsonValues["formatter"] = "link";
                    if (!string.IsNullOrEmpty(formatter2.Target))
                    {
                        hashtable["target"] = formatter2.Target;
                    }
                }
                if (formatter is EmailFormatter)
                {
                    this._jsonValues["formatter"] = "email";
                }
                if (formatter is IntegerFormatter)
                {
                    IntegerFormatter formatter3 = (IntegerFormatter)formatter;
                    this._jsonValues["formatter"] = "integer";
                    if (!string.IsNullOrEmpty(formatter3.ThousandsSeparator))
                    {
                        hashtable["thousandsSeparator"] = formatter3.ThousandsSeparator;
                    }
                    if (!string.IsNullOrEmpty(formatter3.DefaultValue))
                    {
                        hashtable["defaultValue"] = formatter3.DefaultValue;
                    }
                }
                if (formatter is NumberFormatter)
                {
                    NumberFormatter formatter4 = (NumberFormatter)formatter;
                    this._jsonValues["formatter"] = "integer";
                    if (!string.IsNullOrEmpty(formatter4.ThousandsSeparator))
                    {
                        hashtable["thousandsSeparator"] = formatter4.ThousandsSeparator;
                    }
                    if (!string.IsNullOrEmpty(formatter4.DefaultValue))
                    {
                        hashtable["defaultValue"] = formatter4.DefaultValue;
                    }
                    if (!string.IsNullOrEmpty(formatter4.DecimalSeparator))
                    {
                        hashtable["decimalSeparator"] = formatter4.DecimalSeparator;
                    }
                    if (formatter4.DecimalPlaces != -1)
                    {
                        hashtable["decimalPlaces"] = formatter4.DecimalPlaces;
                    }
                }
                if (formatter is CurrencyFormatter)
                {
                    CurrencyFormatter formatter5 = (CurrencyFormatter)formatter;
                    this._jsonValues["formatter"] = "currency";
                    if (!string.IsNullOrEmpty(formatter5.ThousandsSeparator))
                    {
                        hashtable["thousandsSeparator"] = formatter5.ThousandsSeparator;
                    }
                    if (!string.IsNullOrEmpty(formatter5.DefaultValue))
                    {
                        hashtable["defaultValue"] = formatter5.DefaultValue;
                    }
                    if (!string.IsNullOrEmpty(formatter5.DecimalSeparator))
                    {
                        hashtable["decimalSeparator"] = formatter5.DecimalSeparator;
                    }
                    if (formatter5.DecimalPlaces != -1)
                    {
                        hashtable["decimalPlaces"] = formatter5.DecimalPlaces;
                    }
                    if (!string.IsNullOrEmpty(formatter5.Prefix))
                    {
                        hashtable["prefix"] = formatter5.Prefix;
                    }
                    if (!string.IsNullOrEmpty(formatter5.Prefix))
                    {
                        hashtable["suffix"] = formatter5.Suffix;
                    }
                }
                if (formatter is CheckBoxFormatter)
                {
                    CheckBoxFormatter formatter6 = (CheckBoxFormatter)formatter;
                    this._jsonValues["formatter"] = "checkbox";
                    if (formatter6.Enabled)
                    {
                        hashtable["disabled"] = false;
                    }
                }
                if (formatter is CustomFormatter)
                {
                    CustomFormatter formatter7 = (CustomFormatter)formatter;
                    if (!string.IsNullOrEmpty(formatter7.FormatFunction))
                    {
                        this._jsonValues["formatter"] = formatter7.FormatFunction;
                    }
                    if (!string.IsNullOrEmpty(formatter7.UnFormatFunction))
                    {
                        this._jsonValues["unformat"] = formatter7.UnFormatFunction;
                    }
                }
            }
            if (hashtable.Count > 0)
            {
                this._jsonValues["formatoptions"] = hashtable;
            }
        }