private static StringBuilder AppendColumnModelJQueryUIButtonFormatter(this StringBuilder javaScriptBuilder, JqGridColumnFormatterOptions formatterOptions) { StringBuilder jQueryUIButtonFormatterBuilder = new StringBuilder(80); jQueryUIButtonFormatterBuilder.Append(JQUERY_UI_BUTTON_FORMATTER_START); if (!formatterOptions.AreDefault(JqGridPredefinedFormatters.JQueryUIButton)) { jQueryUIButtonFormatterBuilder.AppendJavaScriptObjectOpening() .AppendJavaScriptObjectStringField(JqGridOptionsNames.ColumnModel.Formatter.LABEL, formatterOptions.Label) .AppendJavaScriptObjectBooleanField(JqGridOptionsNames.ColumnModel.Formatter.TEXT, formatterOptions.Text, JqGridOptionsDefaults.ColumnModel.Formatter.Text); if (!String.IsNullOrEmpty(formatterOptions.PrimaryIcon) || !String.IsNullOrEmpty(formatterOptions.SecondaryIcon)) { jQueryUIButtonFormatterBuilder.AppendJavaScriptObjectFieldOpening(JqGridOptionsNames.ColumnModel.Formatter.ICONS) .AppendJavaScriptObjectStringField(JqGridOptionsNames.ColumnModel.Formatter.PRIMARY, formatterOptions.PrimaryIcon) .AppendJavaScriptObjectStringField(JqGridOptionsNames.ColumnModel.Formatter.SECONDARY, formatterOptions.SecondaryIcon) .AppendJavaScriptObjectFieldClosing(); } jQueryUIButtonFormatterBuilder.AppendJavaScriptObjectClosing(); } if (!String.IsNullOrWhiteSpace(formatterOptions.OnClick)) { jQueryUIButtonFormatterBuilder.AppendFormat(JQUERY_UI_BUTTON_FORMATTER_ON_CLICK, formatterOptions.OnClick); } jQueryUIButtonFormatterBuilder.Append(JQUERY_UI_BUTTON_FORMATTER_END); return(javaScriptBuilder.AppendJavaScriptObjectFunctionField(JqGridOptionsNames.ColumnModel.FORMATTER, jQueryUIButtonFormatterBuilder.ToString())); }
private static StringBuilder AppendColumnModelFormatterOptions(this StringBuilder javaScriptBuilder, string formatter, JqGridColumnFormatterOptions formatterOptions) { if ((formatterOptions != null) && !formatterOptions.AreDefault(formatter)) { javaScriptBuilder.AppendJavaScriptObjectFieldOpening(JqGridOptionsNames.ColumnModel.FORMATTER_OPTIONS); switch (formatter) { case JqGridPredefinedFormatters.Integer: javaScriptBuilder.AppendColumnModelIntegerFormatterOptions(formatterOptions); break; case JqGridPredefinedFormatters.Number: javaScriptBuilder.AppendColumnModelNumberFormatterOptions(formatterOptions); break; case JqGridPredefinedFormatters.Currency: javaScriptBuilder.AppendColumnModelCurrencyFormatterOptions(formatterOptions); break; case JqGridPredefinedFormatters.Date: javaScriptBuilder.AppendColumnModelDateFormatterOptions(formatterOptions); break; case JqGridPredefinedFormatters.Link: javaScriptBuilder.AppendColumnModelLinkFormatterOptions(formatterOptions); break; case JqGridPredefinedFormatters.ShowLink: javaScriptBuilder.AppendColumnModelShowLinkFormatterOptions(formatterOptions); break; case JqGridPredefinedFormatters.CheckBox: javaScriptBuilder.AppendColumnModelCheckBoxFormatterOptions(formatterOptions); break; case JqGridPredefinedFormatters.Actions: javaScriptBuilder.AppendColumnModelActionsFormatterOptions(formatterOptions); break; } javaScriptBuilder.AppendJavaScriptObjectFieldClosing(); } return(javaScriptBuilder); }