1- using System ;
2- using System . Collections ;
3- using System . Collections . Generic ;
1+ using System . Collections . Generic ;
42using System . Linq ;
53using System . Net . Mime ;
64using System . Web . Routing ;
119
1210namespace Mvc . JQuery . Datatables
1311{
14- public class FilterDef : Hashtable
15- {
16- internal object [ ] values { set { this [ "values" ] = value ; } }
17- internal string type { set { this [ "type" ] = value ; } }
18-
19-
20- public FilterDef ( Type t )
21- {
22- SetDefaultValuesAccordingToColumnType ( t ) ;
23- }
24-
25- private static List < Type > DateTypes = new List < Type > { typeof ( DateTime ) , typeof ( DateTime ? ) , typeof ( DateTimeOffset ) , typeof ( DateTimeOffset ? ) } ;
26-
27-
28- private void SetDefaultValuesAccordingToColumnType ( Type t )
29- {
30- if ( t == null )
31- {
32- type = "null" ;
33- }
34- else if ( DateTypes . Contains ( t ) )
35- {
36- type = "date-range" ;
37- }
38- else if ( t == typeof ( bool ) )
39- {
40- type = "select" ;
41- values = new object [ ] { "True" , "False" } ;
42- }
43- else if ( t == typeof ( bool ? ) )
44- {
45- type = "select" ;
46- values = new object [ ] { "True" , "False" , "null" } ;
47- }
48- else if ( t . IsEnum )
49- {
50- type = "checkbox" ;
51- values = Enum . GetNames ( t ) . Cast < object > ( ) . ToArray ( ) ;
52- }
53- else
54- {
55- type = "text" ;
56- }
57- }
58- }
59-
6012 public class DataTableConfigVm
6113 {
6214 public bool HideHeaders { get ; set ; }
@@ -327,26 +279,4 @@ private static IDictionary<string, object> convertObjectToDictionary(object obj)
327279 return new Dictionary < string , object > ( new RouteValueDictionary ( obj ) ) ;
328280 }
329281 }
330-
331- public class ColumnFilterSettingsVm : Hashtable
332- {
333- private readonly DataTableConfigVm _vm ;
334-
335- public ColumnFilterSettingsVm ( DataTableConfigVm vm )
336- {
337- _vm = vm ;
338- this [ "bUseColVis" ] = true ;
339- this [ "sPlaceHolder" ] = "head:after" ;
340- }
341-
342- public override string ToString ( )
343- {
344- var noColumnFilter = new FilterDef ( null ) ;
345- this [ "aoColumns" ] = _vm . Columns
346- //.Where(c => c.Visible || c.Filter["sSelector"] != null)
347- . Select ( c => c . Searchable ? c . Filter : noColumnFilter ) . ToArray ( ) ;
348- return new JavaScriptSerializer ( ) . Serialize ( this ) ;
349- }
350- }
351-
352282}
0 commit comments