Skip to content
Browse files

jqGrid Columns can now be set as editable

  • Loading branch information...
1 parent a77358a commit f6b2342ee29ab1320b931d4be5e862463323faff @cmendible committed Aug 21, 2013
Showing with 49 additions and 3 deletions.
  1. +49 −3 Hexa.Core.Web.Mvc/Grid/Grid.cs
View
52 Hexa.Core.Web.Mvc/Grid/Grid.cs
@@ -115,6 +115,9 @@ public class Column
private bool? sortable;
private bool? title;
private int? width;
+ private bool editable;
+ private string editType;
+ private string editOptions;
/// <summary>
/// Constructor
@@ -194,6 +197,36 @@ public Column SetCustomFormatter(string customFormatter)
}
/// <summary>
+ /// Marks the columns as editable.
+ /// </summary>
+ /// <returns>the current column</returns>
+ public Column SetEditable()
+ {
+ this.editable = true;
+ return this;
+ }
+
+ /// <summary>
+ /// Sets the edit type of the column
+ /// </summary>
+ /// <returns>the current column</returns>
+ public Column SetEditType(string editType)
+ {
+ this.editType = editType;
+ return this;
+ }
+
+ /// <summary>
+ /// Sets the edit options of the column
+ /// </summary>
+ /// <returns>the current column</returns>
+ public Column SetEditOptions(string options)
+ {
+ this.editOptions= options;
+ return this;
+ }
+
+ /// <summary>
/// If set to asc or desc, the column will be sorted in that direction on first
/// sort.Subsequent sorts of the column will toggle as usual (default: null)
/// </summary>
@@ -526,6 +559,19 @@ public override string ToString()
script.AppendFormat("width:{0},", this.width.Value).AppendLine();
}
+ if (this.editable)
+ {
+ script.AppendLine("editable:true,").AppendLine();
+ if (!string.IsNullOrWhiteSpace(this.editType))
+ {
+ script.AppendFormat("edittype:'{0}',", this.editType).AppendLine();
+ }
+ if (!string.IsNullOrWhiteSpace(this.editOptions))
+ {
+ script.AppendFormat("editoptions:{0},", this.editOptions).AppendLine();
+ }
+ }
+
// Index
script.AppendFormat("index:'{0}'", this.index).AppendLine();
@@ -653,7 +699,7 @@ public Grid(string id)
/// </summary>
/// <returns>Current Grid instance</returns>
public Grid Add()
- {
+ {
this.add = true;
return this;
}
@@ -2239,7 +2285,7 @@ public override string ToString()
script.AppendLine("grouping: true,");
script.AppendLine("groupingView: {");
script.AppendLine(string.Format(CultureInfo.InvariantCulture, "groupField: ['{0}'],", string.Join("', '", this.groupFields.ToArray())));
-
+
if (this.groupColumnShow.Any())
{
script.AppendLine(string.Format(CultureInfo.InvariantCulture, "groupColumnShow: [{0}],", string.Join(", ", this.groupColumnShow.Select(g => g.ToString().ToLower()).ToArray())));
@@ -2264,7 +2310,7 @@ public override string ToString()
{
script.AppendLine(string.Format(CultureInfo.InvariantCulture, "groupSummary: [{0}],", string.Join(", ", this.groupSummary.Select(g => g.ToString().ToLower()).ToArray())));
}
-
+
script.AppendLine("}");
}

0 comments on commit f6b2342

Please sign in to comment.
Something went wrong with that request. Please try again.