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

RadGrid Filtering not working as it should

2 Answers 311 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 17 Apr 2013, 05:53 PM
I have a radgrid and have enabled filtering. I have restricted the filtering to contains only. The problem is that when I enter in some filter text it fires the ItemCommand event which is fine but, it does not filter the grid. If I re-type the filter string again it fires the ItemCommand event again and the second time and any more subsequent attempts work as expected resulting in the grid being filtered. This is so wierd and I have no idea whi I have to type in a filter string twice to get it to work.

protected void policeGrid_ItemCommand(object sender, GridCommandEventArgs e)
       {
           if (e.CommandName == "Select")
           {
               var stationId = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["station_id"];
               Session["station_id"] = stationId;
 
               radAjaxMgr.ResponseScripts.Add("radopen('information.aspx','null')");
           }
       }


<telerik:RadWindowManager ID="rw" runat="server" ReloadOnShow="True"></telerik:RadWindowManager>
            <telerik:RadGrid ID="policeGrid" runat="server" AllowSorting="false" Skin="Default" OnNeedDataSource="LoadPoliceTable" OnItemCommand="policeGrid_ItemCommand"
                GridLines="Both" AutoGenerateColumns="False" ShowFooter="false" AllowPaging="true"  AllowFilteringByColumn="true"
                PageSize="25" PagerStyle-AlwaysVisible="true" OnUpdateCommand="policeGrid_UpdateCommand" OnInsertCommand="policeGrid_InsertCommand"
                EnableLinqExpressions="false" OnDeleteCommand="policeGrid_DeleteCommand" GroupingEnabled="True" ShowGroupPanel="True"
                GroupPanel-Enabled="True">
                <ClientSettings AllowDragToGroup="True"/>
                <PagerStyle Mode="NextPrevNumericAndAdvanced" Position="TopAndBottom" />
                <MasterTableView AllowMultiColumnSorting="true" CommandItemDisplay="Top" DataKeyNames="station_id"
                    NoMasterRecordsText="No current police." TableLayout="Fixed" CommandItemSettings-ShowRefreshButton="False">
                    <RowIndicatorColumn Visible="False">
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </RowIndicatorColumn>
                    <Columns>
                        <telerik:GridEditCommandColumn UniqueName="btnEdit" ButtonType="ImageButton" EditText="Edit" Resizable="False" >
                            <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                            <HeaderStyle Width="15px" />
                        </telerik:GridEditCommandColumn>
                        <telerik:GridButtonColumn UniqueName="infoPolice" ButtonType="ImageButton" ImageUrl="../../RadControls/Grid/Skins/info.png" CommandName="Select" Text="Info">
                            <HeaderStyle Width="15px" />
                        </telerik:GridButtonColumn>
                        <telerik:GridBoundColumn DataField="STATION_ID" HeaderText="STATION_ID" UniqueName="STATION_ID"
                            AllowFiltering="True" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" >
                            <HeaderStyle Width="50px" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="PRIMARY_CONTACT_ID" HeaderText="PRIMARY_CONTACT_ID" UniqueName="PRIMARY_CONTACT_ID"
                            AllowFiltering="True" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" >
                            <HeaderStyle Width="50px" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="STATE_NAME" HeaderText="STATE_NAME" UniqueName="STATE_NAME"
                            AllowFiltering="True" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" >
                            <HeaderStyle Width="75px" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="TROOP" UniqueName="TROOP" HeaderText="TROOP"
                            AllowFiltering="True" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false">
                            <HeaderStyle Width="75" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="PH_HAZMAT" HeaderText="PH_HAZMAT" UniqueName="PH_HAZMAT"
                            AllowFiltering="True" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false">
                            <HeaderStyle Width="75px" />
                        </telerik:GridBoundColumn>
                        <telerik:GridButtonColumn ConfirmText="Delete this group?" ConfirmDialogType="RadWindow"
                            ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                            UniqueName="DeleteColumngroups" Visible="true">
                            <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                            <HeaderStyle Width="50px" />
                        </telerik:GridButtonColumn>
                    </Columns>
                    <EditFormSettings UserControlName="EditPolice.ascx" EditFormType="WebUserControl">
                        <EditColumn UniqueName="EditCommandColumn1">
                        </EditColumn>
                    </EditFormSettings>
                </MasterTableView>
            </telerik:RadGrid>

2 Answers, 1 is accepted

Sort by
0
John
Top achievements
Rank 1
answered on 17 Apr 2013, 06:31 PM
After more testing it seems as though this issue is only happening if the grid columns consist of numerical data. Any column that is not number based does not have this issue.
0
Princy
Top achievements
Rank 2
answered on 18 Apr 2013, 03:28 AM
Hi,

Try setting the DataType="System.String" for the Grid Column consisting of numeric data.

ASPX:
<telerik:GridBoundColumn DataField="STATION_ID" HeaderText="STATION_ID" DataType="System.String" UniqueName="STATION_ID"
    AllowFiltering="True" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
    ShowFilterIcon="false">
    <HeaderStyle Width="50px" />
</telerik:GridBoundColumn>

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