@@ -34,7 +34,9 @@ public class DataTablesParser<T> where T : class
3434 * string: sEcho - Information for DataTables to use for rendering
3535 */
3636
37+ private const string INDIVIDUAL_DATA_KEY_PREFIX = "mDataProp_" ;
3738 private const string INDIVIDUAL_SEARCH_KEY_PREFIX = "sSearch_" ;
39+ private const string INDIVIDUAL_SEARCHABLE_KEY_PREFIX = "bSearchable_" ;
3840 private const string INDIVIDUAL_SORT_KEY_PREFIX = "iSortCol_" ;
3941 private const string INDIVIDUAL_SORT_DIRECTION_KEY_PREFIX = "sSortDir_" ;
4042 private const string DISPLAY_START = "iDisplayStart" ;
@@ -315,9 +317,32 @@ private Expression<Func<T, bool>> ApplyGenericSearch
315317
316318 List < MethodCallExpression > searchProps = new List < MethodCallExpression > ( ) ;
317319
320+ var dataNumbers = new Dictionary < int , string > ( ) ;
321+
322+ foreach ( string key in _httpRequest . Params . AllKeys . Where ( x => x . StartsWith ( INDIVIDUAL_DATA_KEY_PREFIX ) ) )
323+ {
324+ // parse the property number
325+ var property = - 1 ;
326+
327+ var propertyString = key . Replace ( INDIVIDUAL_DATA_KEY_PREFIX , string . Empty ) ;
328+
329+ if ( ( ! int . TryParse ( propertyString , out property ) )
330+ || property >= _properties . Length || string . IsNullOrEmpty ( key ) )
331+ break ; // ignore if the option is invalid
332+
333+ dataNumbers . Add ( property , _httpRequest [ key ] ) ;
334+ }
335+
318336 foreach ( var prop in _properties )
319337 {
320- if ( ! prop . CanWrite ) { continue ; }
338+ var searchable = INDIVIDUAL_SEARCHABLE_KEY_PREFIX
339+ + dataNumbers . Where ( d => d . Value == prop . Name ) . Select ( d => d . Key ) . FirstOrDefault ( ) ;
340+
341+ bool isSearchable ;
342+
343+ bool . TryParse ( _httpRequest [ searchable ] , out isSearchable ) ;
344+
345+ if ( ! prop . CanWrite || ! isSearchable ) { continue ; }
321346
322347 Expression stringProp = null ;
323348
0 commit comments