@@ -35,24 +35,7 @@ public static DataTableConfigVm DataTableVm<TController, TResult>(this HtmlHelpe
3535 {
3636 if ( columns == null || ! columns . Any ( ) )
3737 {
38- //var propInfos = typeof (TResult).GetProperties().Where(p => p.GetGetMethod() != null).ToList();
39- var propInfos = DataTablesTypeInfo < TResult > . Properties ;
40- var columnList = new List < ColDef > ( ) ;
41- foreach ( var pi in propInfos )
42- {
43- columnList . Add ( new ColDef ( )
44- {
45- Name = pi . Item1 . Name ,
46- DisplayName = pi . Item2 . DisplayName ?? pi . Item1 . Name ,
47- Sortable = pi . Item2 . Sortable ,
48- Visible = pi . Item2 . Visible ,
49- Searchable = pi . Item2 . Searchable ,
50- Type = pi . Item1 . PropertyType ,
51- SortDirection = pi . Item2 . SortDirection ,
52- MRenderFunction = pi . Item2 . MRenderFunction
53- } ) ;
54- }
55- columns = columnList . ToArray ( ) ;
38+ columns = ColDefs < TResult > ( ) ;
5639 }
5740
5841 var mi = exp . MethodInfo ( ) ;
@@ -63,6 +46,32 @@ public static DataTableConfigVm DataTableVm<TController, TResult>(this HtmlHelpe
6346 return new DataTableConfigVm ( id , ajaxUrl , columns ) ;
6447 }
6548
49+ public static DataTableConfigVm DataTableVm < TResult > ( this HtmlHelper html , string id , Uri uri )
50+ {
51+ return new DataTableConfigVm ( id , uri . ToString ( ) , ColDefs < TResult > ( ) ) ;
52+ }
53+
54+ public static ColDef [ ] ColDefs < TResult > ( )
55+ {
56+ var propInfos = DataTablesTypeInfo < TResult > . Properties ;
57+ var columnList = new List < ColDef > ( ) ;
58+ foreach ( var pi in propInfos )
59+ {
60+ columnList . Add ( new ColDef ( )
61+ {
62+ Name = pi . Item1 . Name ,
63+ DisplayName = pi . Item2 . DisplayName ?? pi . Item1 . Name ,
64+ Sortable = pi . Item2 . Sortable ,
65+ Visible = pi . Item2 . Visible ,
66+ Searchable = pi . Item2 . Searchable ,
67+ Type = pi . Item1 . PropertyType ,
68+ SortDirection = pi . Item2 . SortDirection ,
69+ MRenderFunction = pi . Item2 . MRenderFunction
70+ } ) ;
71+ }
72+ return columnList . ToArray ( ) ;
73+ }
74+
6675 public static DataTableConfigVm DataTableVm ( this HtmlHelper html , string id , string ajaxUrl , params string [ ] columns )
6776 {
6877 return new DataTableConfigVm ( id , ajaxUrl , columns . Select ( c => ColDef . Create ( c , ( string ) null , typeof ( string ) ) ) ) ;
0 commit comments