public static string RemoveQuotesForJavaScriptMethods(string input, CoreGrid grid) { string text = input; foreach (CoreColumn column in grid.Columns) { if (column.Formatter != null) { CoreGridColumnFormatter formatter = column.Formatter; if (formatter is CustomFormatter) { CustomFormatter customFormatter = (CustomFormatter)formatter; string oldValue = $"\"formatter\":\"{customFormatter.FormatFunction}\""; string newValue = $"\"formatter\":{customFormatter.FormatFunction}"; text = text.Replace(oldValue, newValue); oldValue = $"\"unformat\":\"{customFormatter.UnFormatFunction}\""; newValue = $"\"unformat\":{customFormatter.UnFormatFunction}"; text = text.Replace(oldValue, newValue); oldValue = $"\"cellattr\":\"{customFormatter.SetAttributesFunction}\""; newValue = $"\"cellattr\":{customFormatter.SetAttributesFunction}"; text = text.Replace(oldValue, newValue); } } foreach (CoreGridEditClientSideValidator editClientSideValidator in column.EditClientSideValidators) { if (editClientSideValidator is CustomValidator) { CustomValidator customValidator = (CustomValidator)editClientSideValidator; string oldValue2 = $"\"custom_func\":\"{customValidator.ValidationFunction}\""; string newValue2 = $"\"custom_func\":{customValidator.ValidationFunction}"; text = text.Replace(oldValue2, newValue2); } } if (column.EditType == EditType.Custom) { string oldValue3 = $"\"custom_element\":\"{column.EditTypeCustomCreateElement}\""; string newValue3 = $"\"custom_element\":{column.EditTypeCustomCreateElement}"; text = text.Replace(oldValue3, newValue3); oldValue3 = $"\"custom_value\":\"{column.EditTypeCustomGetValue}\""; newValue3 = $"\"custom_value\":{column.EditTypeCustomGetValue}"; text = text.Replace(oldValue3, newValue3); } if ((column.Editable && column.EditType == EditType.DatePicker) || column.EditType == EditType.AutoComplete) { string attachEditorsFunction = CoreGridUtil.GetAttachEditorsFunction(grid, column.EditType.ToString().ToLower(), column.EditorControlID); text = text.Replace("\"attachEditControlsScript" + column.DataField + "\"", attachEditorsFunction); text = text.Replace("\"dataInit\"", "dataInit"); } if ((column.Searchable && column.SearchType == SearchType.DatePicker) || column.SearchType == SearchType.AutoComplete) { string attachEditorsFunction2 = CoreGridUtil.GetAttachEditorsFunction(grid, column.SearchType.ToString().ToLower(), column.SearchControlID); text = text.Replace("\"attachSearchControlsScript" + column.DataField + "\"", attachEditorsFunction2); text = text.Replace("\"dataInit\"", "dataInit"); } } return(text); }
private void ApplyFormatterOptions(CoreColumn 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) { CoreGridColumnFormatter formatter = column.Formatter; if (formatter is LinkFormatter) { LinkFormatter linkFormatter = (LinkFormatter)formatter; _jsonValues["formatter"] = "link"; if (!string.IsNullOrEmpty(linkFormatter.Target)) { hashtable["target"] = linkFormatter.Target; } } if (formatter is EmailFormatter) { _jsonValues["formatter"] = "email"; } if (formatter is IntegerFormatter) { IntegerFormatter integerFormatter = (IntegerFormatter)formatter; _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; _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; _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; _jsonValues["formatter"] = "checkbox"; if (checkBoxFormatter.Enabled) { hashtable["disabled"] = false; } } if (formatter is CustomFormatter) { CustomFormatter customFormatter = (CustomFormatter)formatter; if (!string.IsNullOrEmpty(customFormatter.FormatFunction)) { _jsonValues["formatter"] = customFormatter.FormatFunction; } if (!string.IsNullOrEmpty(customFormatter.UnFormatFunction)) { _jsonValues["unformat"] = customFormatter.UnFormatFunction; } if (!string.IsNullOrEmpty(customFormatter.SetAttributesFunction)) { _jsonValues["cellattr"] = customFormatter.SetAttributesFunction; } } } if (hashtable.Count > 0) { _jsonValues["formatoptions"] = hashtable; } }