russko В конференциях этот вопрос обсуждался. Есть, по крайней мере, три варианта решения.
1. Предлагается сделать так, как сделано в Firefox или Thunderbird (используется авто фильтр):
"Sinan Demir - DX Squad wrote:
I like the "Firefox" (TM) way:
OnKeyDown, show a filterpanel at the bottom and send the key to the
editor there.
Build the whole search logic into this filterpanel / class.
> I would like to implement a search feature similar to Firefox or
> Thunderbird also. Where a user can type a word and the grid display
> all records where that word appears in any column.
> Any ideas on the easiest way to achieve this?
this could work:
sFilterString := '%' + edSearch.Text + '%';
with cxGridTableView.DataController.Filter.Root do
begin
Clear;
BoolOperatorKind := fboOr;
For i := 0 to cxGridTableView.ItemCount - 1 do
AddItem(cxGridTableView.Items[i], foLike,
sFilterString, sFilterString);
end;
cxGridTableView.DataController.Filter.Active := True;"
2. Можно использовать компонент xcxGridQuickSearch6 (в свободном доступе
http://www.oratool.de/components/index.html) Там, если в панели фильтрации перед текстом набирать "%" - PercentWildcard, то идет
фильтрация по символам внутри слов. Можно, слегка изменив исходник, PercentWildcard добавлять в текст программно.
3. Радикальный вариант, связанный с правкой реализации Incremental Search:
"Hi Mark,
Yes, your conclusion is correct, you need to alter some sections that
make use of the CompareText() function. In addition, you will want to
modify the text selection display code used by the incremental search
feature, since it only supports selecting from the first char.
Here are the changes I implemented to have the incremental search
feature fully support searching inside words:
- in cxDataUtils.pas, I added a new global text comparison function:
function PosSubstring(const Str, SubStr: string): integer;
begin
Result := -1;
try
Result := Pos(AnsiUpperCase(SubStr), AnsiUpperCase(Str)) - 1;
except
end;
end;
- then in cxCustomData.pas, function TcxDataControllerSearch.DoSearch, I
made the following change:
commented out this line: if DataCompareText(S, ASubText, True) then
added this line instead: if PosSubstring(S, ASubText) <> -1 then
- then in cxGridCustomTableView.pas, procedure
TcxGridTableDataCellViewInfo.InitTextSelection, I made the following change:
commented out this line: SelStart := 0;
added this line instead: SelStart := PosSubstring(GetText,
Controller.IncSearchingText);"