@@ -15,52 +15,45 @@ public class MVCGridConfig
1515 {
1616 public static void RegisterGrids ( )
1717 {
18- MVCGridDefinitionTable . Add ( "TestGrid" , new MVCGridBuilder < Person > ( )
18+ ColumnDefaults colDefauls = new ColumnDefaults ( )
19+ {
20+ EnableSorting = true
21+ } ;
22+
23+ MVCGridDefinitionTable . Add ( "TestGrid" , new MVCGridBuilder < Person > ( colDefauls )
1924 . WithAuthorizationType ( AuthorizationType . AllowAnonymous )
20- . WithSorting ( true , "Id" , SortDirection . Dsc )
21- . WithPaging ( true , 10 , true , 100 )
25+ . WithSorting ( sorting : true , defaultSortColumn : "Id" , defaultSortDirection : SortDirection . Dsc )
26+ . WithPaging ( paging : true , itemsPerPage : 10 , allowChangePageSize : true , maxItemsPerPage : 100 )
2227 . WithAdditionalQueryOptionNames ( "search" )
2328 . AddColumns ( cols =>
2429 {
25- cols . Add ( new GridColumn < Person > ( )
26- {
27- ColumnName = "Id" ,
28- EnableSorting = true ,
29- HtmlEncode = false ,
30- ValueExpression = ( p , c ) => c . UrlHelper . Action ( "detail" , "demo" , new { id = p . Id } ) ,
31- ValueTemplate = "<a href='{Value}'>{Model.Id}</a>" ,
32- PlainTextValueExpression = ( p , c ) => p . Id . ToString ( )
33- } ) ;
30+ cols . Add ( "Id" ) . WithValueExpression ( ( p , c ) => c . UrlHelper . Action ( "detail" , "demo" , new { id = p . Id } ) )
31+ . WithValueTemplate ( "<a href='{Value}'>{Model.Id}</a>" , false )
32+ . WithPlainTextValueExpression ( p => p . Id . ToString ( ) ) ;
3433 cols . Add ( "FirstName" ) . WithHeaderText ( "First Name" )
35- . WithSorting ( true )
36- . WithAllowChangeVisibility ( true )
37- . WithValueExpression ( ( p , c ) => p . FirstName ) ;
34+ . WithVisibility ( true , true )
35+ . WithValueExpression ( p => p . FirstName ) ;
3836 cols . Add ( "LastName" ) . WithHeaderText ( "Last Name" )
39- . WithSorting ( true )
40- . WithAllowChangeVisibility ( true )
41- . WithValueExpression ( ( p , c ) => p . LastName ) ;
37+ . WithVisibility ( true , true )
38+ . WithValueExpression ( p => p . LastName ) ;
4239 cols . Add ( "FullName" ) . WithHeaderText ( "Full Name" )
4340 . WithValueTemplate ( "{Model.FirstName} {Model.LastName}" )
44- . WithVisibility ( false )
45- . WithAllowChangeVisibility ( true )
41+ . WithVisibility ( visible : false , allowChangeVisibility : true )
4642 . WithSorting ( false ) ;
4743 cols . Add ( "StartDate" ) . WithHeaderText ( "Start Date" )
48- . WithSorting ( true )
49- . WithAllowChangeVisibility ( true )
50- . WithValueExpression ( ( p , c ) => p . StartDate . HasValue ? p . StartDate . Value . ToShortDateString ( ) : "" ) ;
44+ . WithVisibility ( visible : true , allowChangeVisibility : true )
45+ . WithValueExpression ( p => p . StartDate . HasValue ? p . StartDate . Value . ToShortDateString ( ) : "" ) ;
5146 cols . Add ( "Status" )
5247 . WithSortColumnData ( "Active" )
53- . WithSorting ( true )
54- . WithAllowChangeVisibility ( true )
48+ . WithVisibility ( visible : true , allowChangeVisibility : true )
5549 . WithHeaderText ( "Status" )
56- . WithValueExpression ( ( p , c ) => p . Active ? "Active" : "Inactive" )
57- . WithCellCssClassExpression ( ( p , c ) => p . Active ? "success" : "danger" ) ;
50+ . WithValueExpression ( p => p . Active ? "Active" : "Inactive" )
51+ . WithCellCssClassExpression ( p => p . Active ? "success" : "danger" ) ;
5852 cols . Add ( "Gender" ) . WithValueExpression ( ( p , c ) => p . Gender )
5953 . WithAllowChangeVisibility ( true ) ;
6054 cols . Add ( "Email" )
61- . WithVisibility ( false )
62- . WithAllowChangeVisibility ( true )
63- . WithValueExpression ( ( p , c ) => p . Email ) ;
55+ . WithVisibility ( visible : false , allowChangeVisibility : true )
56+ . WithValueExpression ( p => p . Email ) ;
6457 cols . Add ( "Url" ) . WithVisibility ( false )
6558 . WithValueExpression ( ( p , c ) => c . UrlHelper . Action ( "detail" , "demo" , new { id = p . Id } ) ) ;
6659 } )
@@ -111,11 +104,6 @@ public static void RegisterGrids()
111104 } )
112105 ) ;
113106
114- ColumnDefaults colDefauls = new ColumnDefaults ( )
115- {
116- EnableSorting = true
117- } ;
118-
119107 MVCGridDefinitionTable . Add ( "SortableGrid" , new MVCGridBuilder < Person > ( colDefauls )
120108 . WithAuthorizationType ( AuthorizationType . AllowAnonymous )
121109 . AddColumns ( cols =>
0 commit comments