@@ -35,24 +35,7 @@ public static DataTableConfigVm DataTableVm<TController, TResult>(this HtmlHelpe
35
35
{
36
36
if ( columns == null || ! columns . Any ( ) )
37
37
{
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 > ( ) ;
56
39
}
57
40
58
41
var mi = exp . MethodInfo ( ) ;
@@ -63,6 +46,32 @@ public static DataTableConfigVm DataTableVm<TController, TResult>(this HtmlHelpe
63
46
return new DataTableConfigVm ( id , ajaxUrl , columns ) ;
64
47
}
65
48
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
+
66
75
public static DataTableConfigVm DataTableVm ( this HtmlHelper html , string id , string ajaxUrl , params string [ ] columns )
67
76
{
68
77
return new DataTableConfigVm ( id , ajaxUrl , columns . Select ( c => ColDef . Create ( c , ( string ) null , typeof ( string ) ) ) ) ;
0 commit comments