Ticket Q295621
Visible to All Users

Filter the display text in all rows and columns

created 14 years ago

I am wondering if there is a possibilty to filter all display texts of the actual grid table view.
The user types in a search text in a TEdit search field in a menu bar for instance and the grid will be filtered with expression %filter term% in all columns and rows.
Only the rows with minimum one cell that matches the filter term have to remain in the grid.

Comments (3)
DevExpress Support Team 14 years ago

    Hello Robert,
    Thank you for your message.
    You van use the TcxFilterCriteria object and create the necessary filter condition ta runtime:

    Delphi
    procedure TForm1.Button1Click(Sender: TObject); var AView: TcxGridDBTableView; I: Integer; s: string; begin AView := cxGrid1DBTableView1; AView.DataController.Filter.Clear; AView.DataController.Filter.Root.Clear; AView.DataController.Filter.Root.BoolOperatorKind := fboOr; s := '%' + cxTextEdit1.Text + '%'; for I := 0 to AView.ColumnCount - 1 do AView.DataController.Filter.Root.AddItem(AView.Columns[I],foLike,s,s); AView.DataController.Filter.Active := True; end;

    Attached is a sample project, demonstrating how to accomplish this.
    For more information, please read the "TcxFilterCriteria Object", "TcxFilterCriteria.Root" and "Example: TcxFilterCriteriaItemList.AddItem, TcxFilterCriteriaItemList.AddItemList, TcxFilterCriteria.Root, TcxFilterCriteria.BeginUpdate, TcxFilterCriteria.EndUpdate" topics.
    Thanks,
    Valdemar

      Hello Valdemar,
      thank you very much for your example.
      I tested it and saw that you use only string columns.
      Your example doesn't function with other data types like integer and date columns.
      How can I implement filtering for these columns too?

      DevExpress Support Team 14 years ago

        Hello Robert,
        The easiest way to accomplish this task is to add a calculated string field for a non-string column and use the solution, described above.
        Or you can add an unbound boolean column to your Grid and obtain all Grid cells texts by using the <GridView>.DataController.DisplayTexts property, to fill this unbound column. Now, you can filter Grid by your unbound column and hide necessary records.
        For more information, please read the "TcxCustomDataController.DisplayTexts" topic and review the A1095(How to set up an unbound item in a data-aware View) Knowledge Base Article.
        Thanks,
        Valdemar

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.