Bug Report S91930
Visible to All Users

ASPxGridView - Provide a grid level setting to change the default Auto Filter Condition

created 17 years ago (modified 10 years ago)

If I have to put an AutoFilterCondition of "Contains" for all the columns in the grid, there is not easier way than putting the line:

ASPx
<Settings AutoFilterCondition="Contains" />

inside each column. This is pretty annoying as one can have a dozen columns in the grid, and to specify filtering conditions for each column can be a pain.

TEMPORARY SOLUTION:

When defining the ASPxGridView.Columns collection manually (AutoGenerateColumns="False"), it is possible to change the default AutoFilterCondition in the following manner:
- Handle the ASPxGridView.Init event;
- Iterate through all GridViewDataColumns in the ASPxGridView.Columns;
- Change the AutoFilterCondition (for example, set it to the "Contains"):

ASPx
<dx:ASPxGridView ID="gv" AutoGenerateColumns="False" OnInit="gv_Init">
C#
protected void gv_Init(object sender, EventArgs e) { ASPxGridView gridView = (ASPxGridView)sender; foreach(GridViewColumn column in gridView.Columns) { if(column is GridViewDataColumn) { ((GridViewDataColumn)column).Settings.AutoFilterCondition = AutoFilterCondition.Contains; } } }
Visual Basic
Protected Sub gv_Init(ByVal sender As Object, ByVal e As EventArgs) Dim gridView As ASPxGridView = CType(sender, ASPxGridView) For Each column As GridViewColumn In gridView.Columns If TypeOf column Is GridViewDataColumn Then CType(column, GridViewDataColumn).Settings.AutoFilterCondition = AutoFilterCondition.Contains End If Next column End Sub

When binding the ASPxGridView.Columns automatically from the datasource (AutoGenerateColumns="True"), it is possible to change the default AutoFilterCondition in the following manner:
- Handle the ASPxGridView.DataBound event;
- Iterate through all GridViewDataColumns in the ASPxGridView.Columns;
- Change the AutoFilterCondition (for example, set it to the "Contains"):

ASPx
<dx:ASPxGridView ID="gv" ... AutoGenerateColumns="True" OnDataBound="gv_DataBound">
C#
protected void gv_DataBound(object sender, EventArgs e) { ASPxGridView gridView = (ASPxGridView)sender; foreach(GridViewColumn column in gridView.Columns) { if(column is GridViewDataColumn) { ((GridViewDataColumn)column).Settings.AutoFilterCondition = AutoFilterCondition.Contains; } } }
Visual Basic
Protected Sub gv_DataBound(ByVal sender As Object, ByVal e As EventArgs) Dim gridView As ASPxGridView = CType(sender, ASPxGridView) For Each column As GridViewColumn In gridView.Columns If TypeOf column Is GridViewDataColumn Then CType(column, GridViewDataColumn).Settings.AutoFilterCondition = AutoFilterCondition.Contains End If Next column End Sub

Proposed Solution:
Have a grid-level setting for AutoFilterCondition as well i.e.
<Grid>
<Settings AutoFilterCondition="BeginsWith or Contains … etc"/>
</Grid>
When column level settings for filtering are specified even though grid level setting is in place, the column level setting will override the grid-level setting.
For e.g.
<Grid>
<Settings AutoFilterCondition="Contains"/>
<Columns>
<Column1 …>
<Settings AutoFilterCondition="Equals"/>
</Column1>
<Column2 …></Column2>
</Columns>
</Grid>
In the above case Column2 will still do a "Contains" filtering, but Column1 will perform an "Equals" filtering.

Show previous comments (4)

    I agree with the solution. I ran into the issue and had to change this setting for every single column.

      +1.

        +1.

        Answers approved by DevExpress Support

        created 9 years ago

        We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

        Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

        Additional information:

        We have implemented the new ASPxGridView.Settings.AutoFilterCondition property.
        Note that the specified link will be available with the next major release 16.1.

          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.