locked
Problem with Telerik Filtering RRS feed

  • Question

  • User-314104254 posted

    Dear all , i`m using ASP MVC 2 with Telerik Grid view,, when i enabled the filtering property , it appear but didn`t filter on the grid 

    Why ?

    Tuesday, September 10, 2013 7:38 AM

Answers

All replies

  • Wednesday, September 11, 2013 12:15 AM
  • User-37275327 posted

    Check in different browsers, chrome or FF. I came across that functionality doesnt work in IE 10.

    Wednesday, September 11, 2013 1:25 AM
  • User-417640953 posted

    Hello,

    Based on your description, I see that you want a filterable Telerik Grid and your grid can not be filtered.

    For this issue, I made a demo.

    Class:

    public class Order {
    
            public int OrderID { get; set; }
            public string ContactName { get; set; }
            public string ShipAddress { get; set; }
            public string OrderDate { get; set; }
        
        }

    Get Records:

     public List<Order> GetDataTable()
             {
                 return new List<Order>(){ 
                     new Order{ OrderID=1, ContactName="AA", ShipAddress="aa", OrderDate="2013/9/11"},
                     new Order{ OrderID=2, ContactName="BB", ShipAddress="aa", OrderDate="2013/9/11"},
                     new Order{ OrderID=3, ContactName="CC", ShipAddress="aa", OrderDate="2013/9/11"},
                     new Order{ OrderID=4, ContactName="DD", ShipAddress="aa", OrderDate="2013/9/11"},
                     new Order{ OrderID=5, ContactName="EE", ShipAddress="aa", OrderDate="2013/9/11"},
                     new Order{ OrderID=6, ContactName="FF", ShipAddress="aa", OrderDate="2013/9/11"}
                     };
             }

    View:

    <%= Html.Telerik().Grid(Model)
            .Name("Grid")
            .Columns(columns =>
            {
                columns.Bound(o => o.OrderID).Width(120);
                columns.Bound(o => o.ContactName).Width(200);
                columns.Bound(o => o.ShipAddress);
                columns.Bound(o => o.OrderDate).Format("{0:MM/dd/yyyy}").Width(100);
            })
            .DataBinding(dataBinding => dataBinding.Ajax().Select("_FirstLook", "Test"))
            .Pageable()
            .Sortable()
            .Filterable(filtering => filtering
                .ShowOrOption((bool)ViewData["showOrOption"])
                .Filters(filters => filters
                    .Add(o => o.ContactName).StartsWith((string)ViewData["startsWith"])
            ))
    %>
    

    Controller:

           //telerik
             public ActionResult TelerikGridTest(string startsWith, bool? showOrOption)
             {
                 ViewData["startsWith"] = startsWith ?? "Paul";
                 ViewData["showOrOption"] = showOrOption ?? true; 
                 return View(GetDataTable()); 
                 
             }
             [GridAction]
             public ActionResult _FirstLook()
             {
                 return View(new GridModel<Order>
                 {
                     Data = GetDataTable()
                 }); 
             }
    

    For more live samples:

       http://demos.telerik.com/aspnet-mvc/grid/filtering

    It works with MVC2.0. If still can not solve it, please post the code and let us reproduce this scenes then provide further solution.

    Thanks.

     

    Best Regards!

     

    Wednesday, September 11, 2013 4:25 AM
  • User-314104254 posted

    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
    <!-- content start -->

    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadAjaxManager ID="RadAjaxManager2" runat="server">
    <AjaxSettings>
    <telerik:AjaxSetting AjaxControlID="RadGrid1">
    <UpdatedControls>
    <telerik:AjaxUpdatedControl ControlID="RadGrid1"
    LoadingPanelID="RadAjaxLoadingPanel1" UpdatePanelCssClass="" />
    </UpdatedControls>
    </telerik:AjaxSetting>
    </AjaxSettings>
    </telerik:RadAjaxManager>
    </div>
    <div>
    <telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" DataSourceID="SqlDataSource1"
    EnableLinqExpressions="False" ShowStatusBar="True"
    GridLines="None" AllowSorting="True" AllowFilteringByColumn="True" EnableAjax="true"
    BorderStyle="Solid" BorderWidth="1px" AllowPaging="True" OnItemDataBound="RadGrid1_ItemDataBound"
    OnNeedDataSource="RadGrid1_NeedDataSource">
    <ClientSettings>
    <DataBinding FilterParameterType="String">
    </DataBinding>
    </ClientSettings>
    <AlternatingItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
    <MasterTableView DataSourceID="SqlDataSource1" HierarchyLoadMode="Client" AutoGenerateColumns="False"
    AllowFilteringByColumn="true" GroupLoadMode="Client" DataKeyNames="CardId" >
    <DetailTables>
    <telerik:GridTableView runat="server" DataSourceID="SqlDataSource2" BorderColor="Black"
    BorderStyle="Solid" GridLines="Both" AllowFilteringByColumn="false" HierarchyDefaultExpanded="True">
    <ParentTableRelation>
    <telerik:GridRelationFields DetailKeyField="CardId" MasterKeyField="CardId" />
    </ParentTableRelation>
    <CommandItemSettings ExportToPdfText="Export to PDF" />
    <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True">
    <HeaderStyle Width="20px" />
    </RowIndicatorColumn>
    <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True">
    <HeaderStyle Width="20px" />
    </ExpandCollapseColumn>
    <EditFormSettings>
    <EditColumn FilterControlAltText="Filter EditCommandColumn column">
    </EditColumn>
    </EditFormSettings>
    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
    <AlternatingItemStyle HorizontalAlign="Center" VerticalAlign="Top" />
    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
    </telerik:GridTableView>
    </DetailTables>
    <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
    <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
    <HeaderStyle Width="20px"></HeaderStyle>
    </RowIndicatorColumn>
    <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
    <HeaderStyle Width="20px"></HeaderStyle>
    </ExpandCollapseColumn>
    <Columns>

    <telerik:GridTemplateColumn UniqueName="TemplateColumn" HeaderText="Row" AllowFiltering="false">
    <ItemTemplate>
    <asp:Label ID="numberLabel" runat="server" Width="30px" />
    </ItemTemplate>
    <HeaderStyle Width="30px" />
    </telerik:GridTemplateColumn>


    <telerik:GridBoundColumn DataField="CardNo" FilterControlAltText="Filter CardNo column"
    HeaderText="Card id" SortExpression="CardNo" UniqueName="CardNo" AllowFiltering="false">
    </telerik:GridBoundColumn>

    <telerik:GridBoundColumn DataField="Status_Description" FilterControlAltText="Filter Status_Description column"
    HeaderText="Status" SortExpression="Status_Description" UniqueName="Status_Description"
    AutoPostBackOnFilter="true">
    </telerik:GridBoundColumn>

    <telerik:GridBoundColumn DataField="CorporateAccountName" FilterControlAltText="Filter CorporateAccountName column"
    HeaderText="Owner" SortExpression="CorporateAccountName" AllowFiltering="false"
    UniqueName="CorporateAccountName">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="CardCategory" FilterControlAltText="Filter CardCategory column"
    HeaderText="Category" SortExpression="CardCategory" AllowFiltering="false" UniqueName="CardCategory">
    </telerik:GridBoundColumn>

    <telerik:GridBoundColumn DataField="LastTransaction" DataType="System.DateTime" HeaderText="Last Transaction"
    ReadOnly="True" AllowFiltering="false" SortExpression="LastTransaction" UniqueName="LastTransaction"
    FilterControlAltText="Filter LastTransaction column">
    </telerik:GridBoundColumn>

    <telerik:GridBoundColumn DataField="LoyalityPoints" DataType="System.Int32" FilterControlAltText="Filter LoyalityPoints column"
    HeaderText="Loyalty" SortExpression="LoyalityPoints" AllowFiltering="false"
    UniqueName="LoyalityPoints">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="CardId" DataType="System.Int64" Display="false"
    FilterControlAltText="Filter CardId column" HeaderText="CardId" ReadOnly="True"
    AllowFiltering="false" SortExpression="CardId" UniqueName="CardId">
    </telerik:GridBoundColumn>
    </Columns>
    <EditFormSettings>
    <EditColumn FilterControlAltText="Filter EditCommandColumn column">
    </EditColumn>
    </EditFormSettings>
    <ItemStyle BackColor="Transparent" BorderColor="Black" BorderStyle="Solid" HorizontalAlign="Center"
    VerticalAlign="Middle" />
    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
    </MasterTableView>
    <HeaderStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" HorizontalAlign="Center"
    VerticalAlign="Middle" />
    <PagerStyle PageButtonCount="15" EnableSEOPaging="True" />
    <FilterMenu EnableImageSprites="False">
    </FilterMenu>
    </telerik:RadGrid>

    Wednesday, September 11, 2013 4:41 AM
  • User-417640953 posted

    Hi,

    I’m sorry for the late replay.

    According to the code you provided, I see what you are suffering.

    For using Telerik Grid-Filter, we only should following their own role rightly.

    Please try below live sample.

    http://demos.telerik.com/aspnet-ajax/grid/examples/programming/filtertemplate/defaultcs.aspx

    Hope this helps, thanks.

     

    Best Regards!

    Friday, September 13, 2013 12:02 AM
  • User-314104254 posted

    Hi, i would like to thank you for your answer , but i did the view exactly as telerik did , and when i filter the grid reloaded but with the same data( no filter occuerd!!!)

    i wonderd , why the function of filtering and sorting doesn`t work , should we write any thing in the controller ?!!

    Friday, September 13, 2013 7:48 AM
  • User-417640953 posted

    Hi Eng,

    The datasource of Telerik RadGrid if SqlDataSource, so we need not to write something in the controller.

    Below link is a sample Telerik RadGrid +SqlDataSource+Filter feature.

      http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/filtering/defaultcs.aspx

    If still can not solve it, I would like suggest you post this issue to Telerik:

      http://www.telerik.com/community/forums/aspnet-ajax.aspx

    There are many Telerik support or experts will focus your issue and give you further solution. Thanks.

     

    Best Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, September 14, 2013 7:29 AM