如何获得Telerik的网格过滤基于previous页面选择 [英] How to get a Telerik Grid filtered based on previous page selection
问题描述
我试图做的事: -
What I'm trying to do:-
索引页将有说类别的下拉列表中,选择1然后提交,重定向到Telerik的网格页面中的所有记录从所选类别的一大桌保管。
Index page would have a dropdown of say categories, select 1 then submit, redirected to telerik grid page with all records kept from a big table of selected category.
因此,例如宠物商店,下拉哪种类型的宠物店里有那么下一个页面上的网格填充了类型,店里有可用的所有宠物的今天。
so for example pet store, dropdown for which type of pets the store has then on next page a grid is populated with all pets of that type which the store has available today.
已经有了自认为排序的日期过滤器的应用到数据绑定。
already got the date filter sorted since that's applied to the databind.
数据库是通过EDMX连接,它有2个表,没有关系,但说哪个更加细化每一类/宠物类别/宠物表,再有就是有一类/宠物栏的记录表其中2个表有单场incommon。
database is connection via an edmx, it has 2 table with no relationships but there is say a category/pet table which goes into details for each category/pet and then there is a record table which has a category/pet column of which the 2 tables have that single field incommon.
我一直试图让这个使用的ViewData其中工程下拉&LT完全正常工作;%:Html.DropDownList(类别,(的SelectList)ViewData的[所属分类])%>但没有填充下一页上的网格。
I have been trying to get this to work by using ViewData which works perfectly fine for the drop down <%: Html.DropDownList("category", (SelectList)ViewData["CategoryList"])%> but fails to populate the grid on the next page.
这样的东西像八九不离十 http://demos.telerik.com/aspnet-mvc/网格/ selectionserverside 但如果可能的下拉并在2页。
so something sorta like http://demos.telerik.com/aspnet-mvc/grid/selectionserverside but if possible with a dropdown and across 2 pages.
推荐答案
从文档。
的 Telerik的电网为ASP.NET MVC正在利用其内置的基于Linq的-EX pression引擎来执行电网运行 - 分页,排序和过滤。然而,在一些情况下,开发者可能希望绕过前pression发动机和页面,排序或通过自己筛选网格数据。这就是所谓的自定义绑定。的
继承人的链接:
<一个href=\"http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-grid-data-binding-custom-binding.html\" rel=\"nofollow\">http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-grid-data-binding-custom-binding.html
按照实施例;如果这是你的控制器加载你的页面:
as per the example; if this was your controller that loaded your page:
[GridAction]
public ActionResult Index(GridCommand command)
{
IEnumerable<Order> data = GetData(command);
var dataContext = new NorthwindDataContext();
//Required for pager configuration
ViewData["total"] = dataContext.Orders.Count();
return View(data);
}
那么你的回发是你可以过滤这样的地方:
Then your post back would be a place you could filter this:
[GridAction]
[HttpPost]
public ActionResult Index(GridCommand command)
{
desiredCategory = this.myDropDownList.SelectedCategory.ToString();
//Change the query here using post back variables
IEnumerable<Order> data = GetData(command);
data = from x in data.[entity name]
where x.category = desiredCategory
select x;
var dataContext = new NorthwindDataContext();
//Required for pager configuration
ViewData["total"] = dataContext.Orders.Count();
return View(data);
}
这篇关于如何获得Telerik的网格过滤基于previous页面选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!