Guides/Hiding-Fields-in-Filters.md
... ...
@@ -0,0 +1,33 @@
1
+[[_TOC_]]
2
+
3
+##Purpose
4
+
5
+Hiding fields in filters is a way to disallow filtering on certain fields. You can programmatically prevent access to fields in the filters tab based on any arbitrary logic you wish to employ.
6
+
7
+##Example
8
+
9
+In this example, I'm arbitrarily disallowing the user to filter on any field with the word "Ship" in it.
10
+
11
+##Implementation
12
+
13
+There is a rather simple override to implement this functionality in your Global.asax. The function is IsFieldAllowedInFilters and has the following signature.
14
+
15
+```csharp
16
+public override bool IsFieldAllowedInFilters(string fullColumnName, string tableName, string columnName) {
17
+ base.IsFieldAllowedInFilters(fullColumnName, tableName, columnName);
18
+ }
19
+```
20
+
21
+Here is the override used to achieve the results in the Example section:
22
+
23
+```csharp
24
+public override bool IsFieldAllowedInFilters(string fullColumnName, string tableName, string columnName) {
25
+ if (columnName.Contains("Ship")) {
26
+ return false;
27
+ }
28
+ else
29
+ return true;
30
+ }
31
+```
32
+
33
+Your logic can be easily amended to target individual columns, or even entire tables worth of columns.
... ...
\ No newline at end of file