public void ChangeGlobalFilterToContainsCaseInsensitive(FilterRowsAction type, string newValueRaw) { var newValue = newValueRaw.ToLower(); ChangeGlobalFilter(type, (col, record) => (col.TextValueFor(record) ?? "").ToLower().Contains(newValue)); }
public void ChangeGlobalFilterToBeginsWithOrAnyWordBeginsCaseInsensitive(FilterRowsAction type, string newValueRaw) { var newValue = newValueRaw.ToLower(); ChangeGlobalFilter(type, (col, record) => { var itm = (col.TextValueFor(record) ?? "").ToLower(); return (itm.StartsWith(newValue) || itm.Split(WhiteSpaceToSplitOn) .Any(wrd => wrd.StartsWith(newValue))); }); }
//single column match public void ChangeGlobalFilter(FilterRowsAction type, Func <IDataGridColumn <RecordT>, RecordT, bool> matches) { ChangeGlobalFilter(collector => { switch (type) { case FilterRowsAction.Remove: break; case FilterRowsAction.Change: collector.AddWhereRule( record => Columns.FirstOrDefault(col => matches(col, record)), found => found != null ); break; default: Logger.Error(GetType(), "Unknown FilterRowsAction in OnGlobalFilterChanged()"); throw new Exception("Unknown FilterRowsAction"); } }); }
public void ChangeGlobalFilterToAllPhrasesContainedInSomeColumnCaseInsensitive(FilterRowsAction type, string userFilterInput) { var phrases = new Regex(@"\w+") .Matches(userFilterInput.ToLower()) .Cast <Match>() .Where(x => x.Success) .Select(x => x.Value) .ToArray(); ChangeGlobalFilter(type, (richCols, record) => { var cols = richCols .Select(col => (col.TextValueFor(record) ?? "") .ToLower()) .ToArray(); return(phrases.All(phrase => cols.Any(colTxt => colTxt.Contains(phrase)))); }); }