Skip to content

Commit 251cdd7

Browse files
committed
Added None option for filter
1 parent 59e84e3 commit 251cdd7

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

.vs/config/applicationhost.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163
</site>
164164
<site name="Mvc.JQuery.Datatables.Example" id="2">
165165
<application path="/" applicationPool="Clr4IntegratedAppPool">
166-
<virtualDirectory path="/" physicalPath="C:\Users\Harry\Dropbox\stuff\mvc.jquery.datatables\Mvc.JQuery.Datatables.Example" />
166+
<virtualDirectory path="/" physicalPath="C:\Users\Harry\Dropbox\stuff\Mvc.JQuery.DataTables2\Mvc.JQuery.DataTables.Example" />
167167
</application>
168168
<bindings>
169169
<binding protocol="http" bindingInformation="*:53281:localhost" />

Mvc.JQuery.Datatables.Core/DataTablesFilterAttribute.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,22 @@ public DataTablesFilterAttribute(string filterType, params object[] options)
3434
public override void ApplyTo(ColDef colDef, System.Reflection.PropertyInfo pi)
3535
{
3636
colDef.Filter = new FilterDef(pi.GetType());
37-
if (filterType != null) colDef.Filter.type = filterType;
38-
if (options != null && options.Any()) colDef.Filter.values = options;
37+
if (filterType == "none")
38+
{
39+
colDef.Filter = null;
40+
}
41+
else
42+
{
43+
if (filterType != null) colDef.Filter.type = filterType;
44+
if (options != null && options.Any()) colDef.Filter.values = options;
45+
}
3946
}
40-
47+
4148
}
4249

4350
public enum DataTablesFilterType
4451
{
52+
None,
4553
Select,
4654
NumberRange,
4755
DateRange,

Mvc.JQuery.Datatables.Example/Controllers/HomeController.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ public DataTablesResult<UserView> GetUsers(DataTablesParam dataTableParam)
3232
Number = user.Number,
3333
Hired = user.Hired,
3434
IsAdmin = user.IsAdmin,
35-
Salary = user.Salary
35+
Salary = user.Salary,
36+
Thumb = "https://randomuser.me/api/portraits/thumb/men/" + user.Id + ".jpg"
3637
}), dataTableParam,
3738
uv => new
3839
{
3940
Name = "<b>" + uv.Name + "</b>",
40-
Hired = uv.Hired == null ? "&lt;pending&gt;" : uv.Hired.Value.ToShortDateString() + " (" + FriendlyDateHelper.GetPrettyDate(uv.Hired.Value) + ") "
41+
Hired = uv.Hired == null ? "&lt;pending&gt;" : uv.Hired.Value.ToShortDateString() + " (" + FriendlyDateHelper.GetPrettyDate(uv.Hired.Value) + ") ",
42+
Thumb = "<img src='" + uv.Thumb + "' />"
4143
});
4244
}
4345

@@ -87,7 +89,8 @@ public class UserView
8789
[DataTablesExclude]
8890
public string ThisColumnIsExcluded { get { return "asdf"; } }
8991

90-
92+
[DataTablesFilter(DataTablesFilterType.None)]
93+
public string Thumb { get; set; }
9194
}
9295

9396
public class DefaultToStartOf2014Attribute : DataTablesAttributeBase

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,9 @@ If you have a feature request, bug, or a patch, please could you add an example
4545
[![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=mcintyre321&url=https://github.com/mcintyre321/mvc.jquery.datatables&title=Mvc.JQuery.DataTables&language=&tags=github&category=software)
4646

4747
> If you have found this project useful, please consider contributing some documentation - it's the biggest weakness!
48+
49+
50+
THANKS
51+
------
52+
53+
To https://randomuser.me/ for the image thumbnails used in the example site

0 commit comments

Comments
 (0)