This repository was archived by the owner on Jan 8, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,24 @@ public IEnumerable<Column> GetFilteredColumns()
7171 . Where ( _column => ! String . IsNullOrWhiteSpace ( _column . Data ) && _column . Searchable && ! String . IsNullOrWhiteSpace ( _column . Search . Value ) ) ;
7272 }
7373 /// <summary>
74+ /// Get sorted columns on client-side already on the same order as the client requested.
75+ /// The method checks if the column is bound and if it's ordered on client-side.
76+ /// The returned expression can be used with the OrderBy(string sortExpression) extension mehod
77+ /// found here : http://extensionmethod.net/csharp/ienumerable-t/orderby-string-sortexpression
78+ /// </summary>
79+ /// <remarks>Added by phayman www.kwiboo.com</remarks>
80+ /// <returns>The ordered enumeration of sorted columns as an expression. e.g. "columnname asc, othercolumn desc"</returns>
81+ public string GetSortedColumnsExpression ( )
82+ {
83+ var sortExpression = new List < string > ( ) ;
84+ foreach ( var column in GetSortedColumns ( ) )
85+ {
86+ sortExpression . Add ( column . Data + " " + ( column . SortDirection == Column . OrderDirection . Descendant ? "desc" : "asc" ) ) ;
87+ }
88+
89+ return String . Join ( "," , sortExpression . ToArray ( ) ) ;
90+ }
91+ /// <summary>
7492 /// Returns the enumerable element as defined on IEnumerable.
7593 /// </summary>
7694 /// <returns>The enumerable elemento to iterate through data.</returns>
You can’t perform that action at this time.
0 commit comments