GithubHelp home page GithubHelp logo

devexpress-examples / winforms-grid-introduce-custom-options-in-auto-filter-row Goto Github PK

View Code? Open in Web Editor NEW
1.0 56.0 1.0 431 KB

Implement new filter options in the Auto Filter Row.

License: Other

C# 56.21% Visual Basic .NET 43.79%
dotnet xtragrid-suite winforms auto-filter-row custom-filter data-filtering data-grid grid-control windows-forms

winforms-grid-introduce-custom-options-in-auto-filter-row's Introduction

WinForms Data Grid - Implement new filter options in the Auto Filter Row

This example creates a custom grid control (MyGridControl) to introduce new filter options. Users can use the following operands to filter DateTime values in columns using the Auto Filter Row: "<", ">", ">=", "<=".

See the implementation of the GridView.CreateAutoFilterCriterion method:

protected override DevExpress.Data.Filtering.CriteriaOperator CreateAutoFilterCriterion(DevExpress.XtraGrid.Columns.GridColumn column, DevExpress.XtraGrid.Columns.AutoFilterCondition condition, object _value, string strVal) {
    if (column.ColumnType == typeof(DateTime) && strVal.Length > 0) {
        BinaryOperatorType type = BinaryOperatorType.Equal;
        string operand = string.Empty;
        if (strVal.Length > 1) {
            operand = strVal.Substring(0, 2);
            if (operand.Equals(">="))
                type = BinaryOperatorType.GreaterOrEqual;
            else if (operand.Equals("<="))
                type = BinaryOperatorType.LessOrEqual;
        }
        if (type == BinaryOperatorType.Equal) {
            operand = strVal.Substring(0, 1);
            if (operand.Equals(">"))
                type = BinaryOperatorType.Greater;
            else if (operand.Equals("<"))
                type = BinaryOperatorType.Less;
        }
        if (type != BinaryOperatorType.Equal) {
            string val = strVal.Replace(operand, string.Empty);
            try {
                DateTime dt = DateTime.ParseExact(val, "d", column.RealColumnEdit.EditFormat.Format);
                return new BinaryOperator(column.FieldName, dt, type);
            }
            catch {
                return null;
            }
        }
    }
    return base.CreateAutoFilterCriterion(column, condition, _value, strVal);
}

Files to Review

Documentation

See Also

winforms-grid-introduce-custom-options-in-auto-filter-row's People

Contributors

devexpressexamplebot avatar iam0k avatar torman999 avatar uriahas avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

fluffybunn

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.