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; } }
public static string RemoveQuotesForJavaScriptMethods(string input, JQGrid grid) { string text = input; foreach (JQGridColumn current in grid.Columns) { 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.DateTimePicker || current.EditType == EditType.TimePicker || current.EditType == EditType.AutoComplete || current.EditType == EditType.Chosen)) { string attachEditorsFunction = GridUtil.GetAttachEditorsFunction(grid, current.EditType.ToString().ToLower(), current.EditorControlID); text = text.Replace(string.Concat(new object[] { '"', "attachEditControlsScript", current.DataField, '"' }), attachEditorsFunction); } if (current.Searchable && (current.SearchType == SearchType.DatePicker || current.SearchType == SearchType.AutoComplete || current.SearchType == SearchType.DateTimePicker || current.SearchType == SearchType.TimePicker)) { string attachEditorsFunction2 = GridUtil.GetAttachEditorsFunction(grid, current.SearchType.ToString().ToLower(), current.SearchControlID); text = text.Replace(string.Concat(new object[] { '"', "attachSearchControlsScript", current.DataField, '"' }), attachEditorsFunction2); } if (current.DataEvents.Count > 0) { List <DataEvent> lde = current.DataEvents.FindAll(f => f.Type != DataEventType.No); if (lde.Count > 0) { foreach (DataEvent de in lde) { string oldValue = string.Format("\"fn\":\"{0}\"", de.Function); string newValue = string.Format("\"fn\":{0}", de.Function); text = text.Replace(oldValue, newValue); } } } if (!string.IsNullOrEmpty(current.DataUrl)) { string oldValue = string.Format("\"dataUrl\":\"{0}\"", current.DataUrl); string newValue = string.Format("\"dataUrl\":{0}", current.DataUrl); text = text.Replace(oldValue, newValue); } if (!string.IsNullOrEmpty(current.BuildSelect)) { string oldValue = string.Format("\"buildSelect\":\"{0}\"", current.BuildSelect); string newValue = string.Format("\"buildSelect\":{0}", current.BuildSelect); text = text.Replace(oldValue, newValue); } if (!string.IsNullOrEmpty(current.SerializeColumnData)) { string oldValue = string.Format("\"postData\":\"{0}\"", current.SerializeColumnData); string newValue = string.Format("\"postData\":{0}", current.SerializeColumnData); text = text.Replace(oldValue, newValue); } if (!string.IsNullOrEmpty(current.DataInit)) { string oldValue = string.Format("\"dataInit\":\"{0}\"", current.DataInit); string newValue = string.Format("\"dataInit\":{0}", current.DataInit); text = text.Replace(oldValue, newValue); } //if (!string.IsNullOrEmpty(current.Complete)) //{ // string oldValue = string.Format("\"complete\":\"{0}\"", current.Complete); // string newValue = string.Format("\"complete\":{0}", current.Complete); // text = text.Replace(oldValue, newValue); //} if (current.EditActionIconsColumn) { if (current.EditActionIconsSettings.ShowEditIcon && !string.IsNullOrEmpty(current.EditActionIconsSettings.onEdit)) { string oldValue = string.Format("\"onEdit\":\"{0}\"", current.EditActionIconsSettings.onEdit); string newValue = string.Format("\"onEdit\":{0}", current.EditActionIconsSettings.onEdit); text = text.Replace(oldValue, newValue); } if (current.EditActionIconsSettings.ShowDeleteIcon) { if (!string.IsNullOrEmpty(current.EditActionIconsSettings.DelErrorTextFormat)) { string oldValue = string.Format("\"errorTextFormat\":\"{0}\"", current.EditActionIconsSettings.DelErrorTextFormat); string newValue = string.Format("\"errorTextFormat\":{0}", current.EditActionIconsSettings.DelErrorTextFormat); text = text.Replace(oldValue, newValue); } if (!string.IsNullOrEmpty(grid.ClientSideEvents.SerializeDelData)) { string oldValue = string.Format("\"serializeDelData\":\"{0}\"", grid.ClientSideEvents.SerializeDelData); string newValue = string.Format("\"serializeDelData\":{0}", grid.ClientSideEvents.SerializeDelData); text = text.Replace(oldValue, newValue); } } } } text = text.Replace('"' + "dataInit" + '"', "dataInit"); return(text); }
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; } }