public static string RemoveQuotesForJavaScriptMethods(string input, JQGrid grid) { string str = input; foreach (JQGridColumn column in grid.Columns) { if (column.Formatter != null) { JQGridColumnFormatter formatter = column.Formatter; if (formatter is CustomFormatter) { CustomFormatter formatter2 = (CustomFormatter)formatter; string oldValue = string.Format("\"formatter\":\"{0}\"", formatter2.FormatFunction); string newValue = string.Format("\"formatter\":{0}", formatter2.FormatFunction); str = str.Replace(oldValue, newValue); oldValue = string.Format("\"unformat\":\"{0}\"", formatter2.UnFormatFunction); newValue = string.Format("\"unformat\":{0}", formatter2.UnFormatFunction); str = str.Replace(oldValue, newValue); } } foreach (JQGridEditClientSideValidator validator in column.EditClientSideValidators) { if (validator is CustomValidator) { CustomValidator validator2 = (CustomValidator)validator; string str4 = string.Format("\"custom_func\":\"{0}\"", validator2.ValidationFunction); string str5 = string.Format("\"custom_func\":{0}", validator2.ValidationFunction); str = str.Replace(str4, str5); } } if (column.EditType == EditType.Custom) { string str6 = string.Format("\"custom_element\":\"{0}\"", column.EditTypeCustomCreateElement); string str7 = string.Format("\"custom_element\":{0}", column.EditTypeCustomCreateElement); str = str.Replace(str6, str7); str6 = string.Format("\"custom_value\":\"{0}\"", column.EditTypeCustomGetValue); str7 = string.Format("\"custom_value\":{0}", column.EditTypeCustomGetValue); str = str.Replace(str6, str7); } if ((column.Editable && (column.EditType == EditType.DatePicker)) || (column.EditType == EditType.AutoComplete)) { string str8 = GridUtil.GetAttachEditorsFunction(grid, column.EditType.ToString().ToLower(), column.EditorControlID); str = str.Replace(string.Concat(new object[] { '"', "attachEditControlsScript", column.DataField, '"' }), str8); str = str.Replace('"' + "dataInit" + '"', "dataInit"); } if ((column.Searchable && (column.SearchType == SearchType.DatePicker)) || (column.SearchType == SearchType.AutoComplete)) { string str9 = GridUtil.GetAttachEditorsFunction(grid, column.SearchType.ToString().ToLower(), column.SearchControlID); str = str.Replace(string.Concat(new object[] { '"', "attachSearchControlsScript", column.DataField, '"' }), str9); str = str.Replace('"' + "dataInit" + '"', "dataInit"); } } return(str); }
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.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); }
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 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 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); }