Пример #1
0
        public static string RemoveQuotesForJavaScriptMethods(string input, JQGrid grid)
        {
            string text = input;

            foreach (JQGridColumn current in grid.Columns)
            {
                if (current.EditActionIconsColumn)
                {
                    string oldValue = string.Format("\"afterSave\":\"{0}\"", current.EditActionIconsSettings.Events.AfterSave ?? "");
                    string newValue = string.Format("\"afterSave\":{0}", current.EditActionIconsSettings.Events.AfterSave ?? "");
                    text     = text.Replace(oldValue, newValue);
                    oldValue = string.Format("\"onSuccess\":\"{0}\"", current.EditActionIconsSettings.Events.OnSuccess ?? "");
                    newValue = string.Format("\"onSuccess\":{0}", current.EditActionIconsSettings.Events.OnSuccess ?? "");
                    text     = text.Replace(oldValue, newValue);
                    oldValue = string.Format("\"onError\":\"{0}\"", current.EditActionIconsSettings.Events.OnError ?? "");
                    newValue = string.Format("\"onError\":{0}", current.EditActionIconsSettings.Events.OnError ?? "");
                    text     = text.Replace(oldValue, newValue);
                }
                if (current.Formatter != null)
                {
                    JQGridColumnFormatter formatter = current.Formatter;
                    if (formatter is CustomFormatter)
                    {
                        CustomFormatter customFormatter = (CustomFormatter)formatter;
                        string          oldValue        = string.Format("\"formatter\":\"{0}\"", customFormatter.FormatFunction);
                        string          newValue        = string.Format("\"formatter\":{0}", customFormatter.FormatFunction);
                        text     = text.Replace(oldValue, newValue);
                        oldValue = string.Format("\"unformat\":\"{0}\"", customFormatter.UnFormatFunction);
                        newValue = string.Format("\"unformat\":{0}", customFormatter.UnFormatFunction);
                        text     = text.Replace(oldValue, newValue);
                    }
                }
                foreach (JQGridEditClientSideValidator current2 in current.EditClientSideValidators)
                {
                    if (current2 is CustomValidator)
                    {
                        CustomValidator customValidator = (CustomValidator)current2;
                        string          oldValue2       = string.Format("\"custom_func\":\"{0}\"", customValidator.ValidationFunction);
                        string          newValue2       = string.Format("\"custom_func\":{0}", customValidator.ValidationFunction);
                        text = text.Replace(oldValue2, newValue2);
                    }
                }
                if (current.EditType == EditType.Custom)
                {
                    string oldValue3 = string.Format("\"custom_element\":\"{0}\"", current.EditTypeCustomCreateElement);
                    string newValue3 = string.Format("\"custom_element\":{0}", current.EditTypeCustomCreateElement);
                    text      = text.Replace(oldValue3, newValue3);
                    oldValue3 = string.Format("\"custom_value\":\"{0}\"", current.EditTypeCustomGetValue);
                    newValue3 = string.Format("\"custom_value\":{0}", current.EditTypeCustomGetValue);
                    text      = text.Replace(oldValue3, newValue3);
                }
                if ((current.Editable && current.EditType == EditType.DatePicker) || current.EditType == EditType.AutoComplete)
                {
                    string attachEditorsFunction = GridUtil.GetAttachEditorsFunction(grid, current.EditType.ToString().ToLower(), current.EditorControlID);
                    text = text.Replace(string.Concat(new object[]
                    {
                        '"',
                        "attachEditControlsScript",
                        current.DataField,
                        '"'
                    }), attachEditorsFunction);
                    text = text.Replace('"' + "dataInit" + '"', "dataInit");
                }
                if ((current.Searchable && current.SearchType == SearchType.DatePicker) || current.SearchType == SearchType.AutoComplete)
                {
                    string attachEditorsFunction2 = GridUtil.GetAttachEditorsFunction(grid, current.SearchType.ToString().ToLower(), current.SearchControlID);
                    text = text.Replace(string.Concat(new object[]
                    {
                        '"',
                        "attachSearchControlsScript",
                        current.DataField,
                        '"'
                    }), attachEditorsFunction2);
                    text = text.Replace('"' + "dataInit" + '"', "dataInit");
                }
            }
            return(text);
        }
Пример #2
0
        private void ApplyFormatterOptions(JQGridColumn column)
        {
            Hashtable hashtable  = new Hashtable();
            Hashtable delOptions = new Hashtable();

            if (column.EditActionIconsColumn)
            {
                hashtable["keys"]       = column.EditActionIconsSettings.SaveOnEnterKeyPress;
                hashtable["editbutton"] = column.EditActionIconsSettings.ShowEditIcon;
                hashtable["delbutton"]  = column.EditActionIconsSettings.ShowDeleteIcon;
                if (!string.IsNullOrEmpty(column.EditActionIconsSettings.Events.AfterSave))
                {
                    hashtable["afterSave"] = column.EditActionIconsSettings.Events.AfterSave;
                }
                if (!string.IsNullOrEmpty(column.EditActionIconsSettings.Events.OnSuccess))
                {
                    hashtable["onSuccess"] = column.EditActionIconsSettings.Events.OnSuccess;
                }
                if (!string.IsNullOrEmpty(column.EditActionIconsSettings.Events.OnError))
                {
                    hashtable["onError"] = column.EditActionIconsSettings.Events.OnError;
                }
                if (!column.EditActionIconsSettings.ReloadAfterDelete)
                {
                    delOptions["reloadAfterSubmit"] = false;
                }
                hashtable["delOptions"] = delOptions;
            }
            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"] = "number";
                    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 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;
            }
        }