This is a migrated thread and some comments may be shown as answers.

RadGrid Filter does not apply on First try to Numeric Column

3 Answers 175 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 20 Jun 2012, 08:39 PM
I am trying to add filters to a RadGrid and am encountering a bug when filtering numeric columns.

Only for columns which are numeric (Int32 for Plant and Demand in this case), the filter does not apply on the first try.  After page load, the first filter on a numeric column simply has no effect.  Any subsequent filter attempt works properly.

This bug does not occur on the date columns nor string columns, as they filter properly.

The data is being loaded by an data object during the NeedDataSource event.  This is the only code behind at the moment. 
I am using the most up to date Telerik with ASP.NET 3.5.

Please see code snippet below:

<telerik:RadGrid runat="server"
    ID="grdOrders" 
    AllowPaging="True"
    AllowSorting="True"
    Skin="Web20"
    onneeddatasource="grdOrders_NeedDataSource"
    GroupingSettings-CaseSensitive="false"
    AllowFilteringByColumn="true"
    >
 
    <MasterTableView AutoGenerateColumns="False"  >
        <Columns>
            <telerik:GridNumericColumn
                DataField="PlantID"
                HeaderText="Plant #"
                AutoPostBackOnFilter="true"
                CurrentFilterFunction="Contains"
                ShowFilterIcon="false"
                SortExpression="PlantID"
                UniqueName="PlantID"
                DataType="System.Int32"
                >
            </telerik:GridNumericColumn>
 
            <telerik:GridBoundColumn
                DataField="Demand"
                HeaderText="Demand"
                AutoPostBackOnFilter="true"
                CurrentFilterFunction="Contains"
                ShowFilterIcon="false"
                SortExpression="Demand"
                UniqueName="Demand"
                DataType="System.Int32"
                >
            </telerik:GridBoundColumn>
 
            <telerik:GridDateTimeColumn
                DataField="OrderEntryDate"
                HeaderText="Order Date"
                CurrentFilterFunction="EqualTo" ShowFilterIcon="false"
                DataFormatString="{0:MM/dd/yyyy}"
                PickerType="DatePicker"
                FilterControlWidth="95px"
                AutoPostBackOnFilter="true"
                SortExpression="OrderEntryDate"
                UniqueName="OrderEntryDate">
            </telerik:GridDateTimeColumn>
 
            <telerik:GridBoundColumn
                DataField="CreatedBy"
                HeaderText="Created By"
                AutoPostBackOnFilter="true"
                CurrentFilterFunction="Contains"
                ShowFilterIcon="false"
                UniqueName="CreatedBy">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
 
    <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True">
    </ClientSettings>
</telerik:RadGrid>

Thanks,
Andy

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Jun 2012, 04:30 AM
Hi,

Try setting the CurrentFilterFunction to 'EqualTo' for the GridNumericColumn.The filter operation 'Contains' are for string types.

ASPX:
<telerik:GridNumericColumn DataField="PlantID" HeaderText="Plant #" AutoPostBackOnFilter="true" CurrentFilterFunction="EqualTo" ShowFilterIcon="false" SortExpression="OrderID" UniqueName="PlantID" DataType="System.Int32"> </telerik:GridNumericColumn>

Thanks,
Shinu.
0
Andrew
Top achievements
Rank 1
answered on 21 Jun 2012, 12:03 PM
Thanks, that fixed my problem.  Is there no way to run a 'Contains' filter on a non-string column?
0
Accepted
Shinu
Top achievements
Rank 2
answered on 22 Jun 2012, 04:41 AM
Hi Andrew,

You can make the CurrentFilterFunction 'Contains' only for String type Columns.The filtering menu options vary by the DataType of the corresponding column.For 'DataType="System.Int32"' you will not get 'Contains' as filter menu option. Try Changing the DataType to System.String.

Thanks,
Shinu.
Tags
Grid
Asked by
Andrew
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Andrew
Top achievements
Rank 1
Share this question
or