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

Filtering RadGrid

3 Answers 139 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ck
Top achievements
Rank 1
ck asked on 04 Mar 2013, 11:22 AM
Hi, I am new to telerik.

I am trying to implement basic filtering on a RadGrid control. the control has a LinqDataSource, as you will see from the snippet below. I can filter data with the "Donated" column which is of type Boolean and it works and the grid gets properly refreshed. however whenever i filter with any other column, be it Date or String it doesn't. I am following the example http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/filtering/defaultcs.aspx and the only difference i can see is the DataSource type, the example uses SQL while i am using Linq.

can anyone point me in the right direction please.
thank you
<telerik:RadGrid ID="PublicationsGrid" runat="server" GridLines="None"
        DataSourceID="PublicationsSource" AllowFilteringByColumn="True"
        AllowSorting="True" PageSize="12" ShowFooter="True" AllowPaging="False"
        AutoGenerateColumns="False" ShowStatusBar="true" EnableLinqExpressions="true">
        <ClientSettings EnableRowHoverStyle="True">
            <Selecting AllowRowSelect="True" EnableDragToSelectRows="False" />
        </ClientSettings>
        <MasterTableView DataSourceID="PublicationsSource" AllowFilteringByColumn="true">
            <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
            <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
            </RowIndicatorColumn>
            <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
            </ExpandCollapseColumn>
            <Columns>
                <telerik:GridBoundColumn DataField="Isbn" FilterControlAltText="Filter Isbn column"
                    HeaderText="Isbn" SortExpression="Isbn" UniqueName="Isbn" AutoPostBackOnFilter="true">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Title" FilterControlAltText="Filter Title column"
                    HeaderText="Title" DataType="System.String" SortExpression="Title" UniqueName="Title" AutoPostBackOnFilter="true">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="PublicationDate" DataFormatString="{0:dd/MM/yyyy}"
                    DataType="System.DateTime" FilterControlAltText="Filter PublicationDate column"
                    HeaderText="Date of publication" SortExpression="PublicationDate" UniqueName="PublicationDate" AutoPostBackOnFilter="true">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Pages" DataType="System.Int32" FilterControlAltText="Filter Pages column"
                    HeaderText="Pages" SortExpression="Pages" UniqueName="Pages" AllowFiltering="False">
                </telerik:GridBoundColumn>
                <telerik:GridCheckBoxColumn DataField="Donated" DataType="System.Boolean" FilterControlAltText="Filter Donated column"
                    HeaderText="Donated" SortExpression="Donated" UniqueName="Donated" AutoPostBackOnFilter="true">
                </telerik:GridCheckBoxColumn>
                <telerik:GridBoundColumn DataField="Cost" DataType="System.Double" FilterControlAltText="Filter Cost column"
                    HeaderText="Cost" SortExpression="Cost" UniqueName="Cost" AllowFiltering="False">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="FullPrice" DataType="System.Double" FilterControlAltText="Filter FullPrice column"
                    HeaderText="Full Price" SortExpression="FullPrice" UniqueName="FullPrice" AllowFiltering="False">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="DiscountPrice" DataType="System.Double" FilterControlAltText="Filter DiscountPrice column"
                    HeaderText="Discount Price" SortExpression="DiscountPrice" UniqueName="DiscountPrice"
                    AllowFiltering="False">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="CurrentStockLevel" DataType="System.Int32" FilterControlAltText="Filter CurrentStockLevel column"
                    HeaderText="Current Stock Level" SortExpression="CurrentStockLevel" UniqueName="CurrentStockLevel"
                    AllowFiltering="False">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Language" FilterControlAltText="Filter Language column"
                    HeaderText="Language" SortExpression="Language" UniqueName="Language" AutoPostBackOnFilter="true">
                </telerik:GridBoundColumn>
            </Columns>
            <EditFormSettings>
                <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                </EditColumn>
            </EditFormSettings>
        </MasterTableView>
        <FilterMenu EnableImageSprites="True">
        </FilterMenu>
    </telerik:RadGrid>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="PublicationsGrid">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="PublicationsGrid"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
    </telerik:RadAjaxLoadingPanel>
    <asp:LinqDataSource ID="PublicationsSource" runat="server" ContextTypeName="App.Business.StockPubContainer"
        EntityTypeName="App.Business.Publication"
        TableName="Publication">
    </asp:LinqDataSource>

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 04 Mar 2013, 12:02 PM
Hi,

When you choose to apply filtering for bound grid column of type DateTime, Telerik RadGrid will filter the records in the corresponding column by fetching the user entry from the filter box in the following format - mm/dd/yyyy. Check the following help documentation which explains more about this.
Filtering for DateTime Bound Column with DataFormatString Different from mm/dd/yyyy

Thanks,
Shinu
0
ck
Top achievements
Rank 1
answered on 04 Mar 2013, 01:02 PM
Hi thanks for your reply.
I actually tried that earlier but it did not work.
now what about string columns, it should be working out of the box i guess ,what am i missing?

regards
0
Pavlina
Telerik team
answered on 08 Mar 2013, 09:37 AM
Hi Chad,

I suggest you try setting EnableLinqExpressions property to false and let me know if this makes any difference. Also ensure that you are using latest version of Telerik.Web.UI assembly.

Greetings,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
ck
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
ck
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or