in
Forums
Blogs
Files
Devexpress.Com
Client Center
Support Center
DevExpress Channel

Problem with retaing the selected filter text in the AspxGridView

Last post 11/20/2008 7:52 AM by Aminur Rouf. 2 replies.
Page 1 of 1 (3 items)
Sort Posts:
Previous Next
  • 11/19/2008 10:28 AM

    Problem with retaing the selected filter text in the AspxGridView

     I have a AspxGridview with a Filter field as:

     

     

     

     

     

     

     

     

     

     

     

     

     

    <dxwgv:GridViewDataComboBoxColumn Caption="Has Duplicates FieldName="NumberOfDuplicates" VisibleIndex="6">

    <PropertiesComboBox ValueType="System.Int32"><Items>

               <dxe:ListEditItem Text="Yes" value="999"

    >

     

     

               <dxe:ListEditItem Text="No" value="0"

    />

     

     

     

    </Items></PropertiesComboBox></dxwgv:GridViewDataComboBoxColumn>

    The field name NumberOfDuplicates is a integer which can have a value of 0 to whatever. I have set up a criteria in the code behind as

         protected void grvPublicationList_ProcessColumnAutoFilter(object sender, ASPxGridViewAutoFilterEventArgs e)
            {
         
                if (e.Column == grvPublicationList.Columns["NumberOfDuplicates"] )
                {
                    if (e.Value == "0")
                    {
                        e.Criteria = new BinaryOperator("NumberOfDuplicates", 0, BinaryOperatorType.Equal);
                    }
                    else
                    {
                        e.Criteria = new BinaryOperator("NumberOfDuplicates", 1, BinaryOperatorType.GreaterOrEqual);
                     
                    }
                }
               
            }

    So if the user selects No, the grid is filtered to find all the records with 0 duplicates. (Don't know why but all the 0's get replaced with "No" in that coloumn).

    And if the user selects Yes, the grid is filtered with all records that have 1 or more. The filtering is working fine.

    However, because I have initially set the ListEditItem Yes with a value of 999 (I know there are no records with 999 NumberOfDuplicates), the selected value in GridViewDataComboBoxColumn becomes a 1 or whatever I have put into the right operand of e.Criteria instead of Yes.

    My question is how can I apply this filter and still keep the selected value to be Yes in the GridViewDataComboBoxColumn  and still display the actual number of duplicates for the records in that coloumn.

  • 11/19/2008 8:35 PM In reply to

    Re: Problem with retaing the selected filter text in the AspxGridView

    Answer

    Hi,

    Not sure about your specific issue but this code central sample may help you: Create the Custom Filter Criteria

  • 11/20/2008 7:52 AM In reply to

    Re: Problem with retaing the selected filter text in the AspxGridView

     Using your example I managed to resolve the problem so thanks.

    I added the following in my cs files

    protected void grvPublicationList_AutoFilterCellEditorCreate(object sender, ASPxGridViewEditorCreateEventArgs e)
            {
                if (!IsCustomColumnFiltering(e.Column)) return;
                 ComboBoxProperties combo = new ComboBoxProperties();
                if (Equals(e.Column, grvPublicationList.Columns["NumberOfDuplicates"]))
                {
                    combo.Items.Add("Yes","1");
                    combo.Items.Add("No","0");
                }
                e.EditorProperties = combo;
            }

    Where as previously I was populating the dropdown in the code behind file using

    <dxe:ListEditItem Text="No" Value="0" > </dxe:ListEditItem>
    <dxe:ListEditItem Text="Yes" Value="1">   </dxe:ListEditItem>  

    I fail to understand why the two methods do not work in the exact same way, nevertheless the problem is resolved.

     

Page 1 of 1 (3 items)
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED