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

[Solved] Filtering in grid doesnt work

1 Answer 39 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
behnam
Top achievements
Rank 1
behnam asked on 22 Nov 2009, 06:21 AM

hi

i have a simple gidview in CustomBinding mode and becuse i use template column i cant use ajax mode.now my prob is that I am unable to get the filtering to work on the Grid.

here is the code :

<%Html.Telerik().Grid<User>(Model)  
                     .Name("Grid")  
                     .Columns(columns =>  
                     {  
                         columns.Add(o =>  
    {  
        %>  
        <%=Ajax.ActionLink("[Edit]", "OpenIEPanel", new { id = o.ID }, new AjaxOptions { UpdateTargetId = "divIEPanel"OnSuccess = "Dialog.Open" }).Replace("[Edit]", "<img src=\"../../Content/images/edit.png\"/>")%>  
        <%                  
            }).Title("Edit").HtmlAttributes(new { @style = "text-align:center" }).Width(75).HeaderHtmlAttributes(new { @style = "text-align: center" });  
                         columns.Add(o =>  
                         {  
        %>  
        <%= Ajax.ActionLink("[Delete]", "Delete", "Grid", new { id = o.ID }, new AjaxOptions { HttpMethod = "POST"Confirm = "ایا از حذف این ایتم اطمینان دارید." }).Replace("[Delete]", "<img src=\"../../Content/images/delete.png\"/>")%>  
        <%       
            }).Title("Delete").HtmlAttributes(new { @style = "text-align:center" }).Width(75).HeaderHtmlAttributes(new { @style = "text-align: center" });  
 
                                                  columns.Add(o => o.Name).HtmlAttributes(new { @style = "text-align:right" }).Width(150).Title("Name").HeaderHtmlAttributes(new { @style = "text-align: center" });  
                                                  columns.Add(o => o.Family).HtmlAttributes(new { @style = "text-align:right" }).Width(150).Title("Family").HeaderHtmlAttributes(new { @style = "text-align: center" });  
                                                  columns.Add(o => o.Job).HtmlAttributes(new { @style = "text-align:right" }).Width(150).Title("Job").HeaderHtmlAttributes(new { @style = "text-align: center" }).Filterable(true);  
                                                  columns.Add(o => o.UserName).HtmlAttributes(new { @style = "text-align:right" }).Width(150).Title("UserName").HeaderHtmlAttributes(new { @style = "text-align: center" });  
                                                  columns.Add(o => o.Password).HtmlAttributes(new { @style = "text-align:right" }).Width(150).Title("Password").HeaderHtmlAttributes(new { @style = "text-align: center" });  
                     })  
        .ServerBinding(settings => settings.Action("Index", "Grid"))  
        .Pageable(settings => settings.PageSize(5).Total((int)ViewData["total"])).HtmlAttributes(new { @style = "direction:lrt" })  
        .EnableCustomBinding(true)  
        .Sortable()  
        .Filterable()  
        .Render(); %> 

public ActionResult Index(GridCommand grid)  
        {  
            return View("Index3", GetData());  
        }  
 
        private IEnumerable <User> GetData()  
        {  
            List<User> data = new DBDataContext().Users.Skip(GridHelper.Skip()).Take(GridHelper.PageNumber).MyOrderBy<User>();  
            ViewData["total"] = new DBDataContext().Users.Count();  
            return data.AsEnumerable();  

        } 

1 Answer, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 23 Nov 2009, 09:01 AM
Hi Behnam,

Can you please confirm that you have a ScriptManager on the page, after the grid, as noted in the online documentation?

All the best,
Alex
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
behnam
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Share this question
or