Telerik的排序网格+ NHibernate的,IQueryable的和ASP.NET MVC [英] sortable telerik grid + NHibernate, IQueryable and ASP.NET MVC

查看:122
本文介绍了Telerik的排序网格+ NHibernate的,IQueryable的和ASP.NET MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得一个Telerik的网格工作(分页正常工作)。我的看法code是这样的:

I am trying to get a telerik grid to work (paging works fine). My view code looks like this:

@(Html.Telerik().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
    columns.Bound(o => o.ItemName.Text).Title("Name");
})
.Pageable(pager => pager.PageSize(20))
.Sortable()
)

我的控制器看起来是这样的:

My controller looks like this:

public ActionResult Index(GridCommand command)
{
   return View(BlaRepository.GetBlas(command.PageSize, command.Page));
}

信息库看起来是这样的:

The repository looks like this:

public IQueryable<Bla> GetBlas(int PageSize, int Page)
{
    var query = (from e in Session.Query<Bla>() select e).AsQueryable();

    return query.Skip((Page - 1) * PageSize).Take(PageSize);
}

据我所知,GridCommand将包含的东西进行排序她:

I understand that the GridCommand will contain things to be sorted her:

command.SortDescriptors

command.SortDescriptors

和我有莫名其妙库结婚这件事(或做我???因为我读的地方,该发动机Telerik的利用了这种关心,如果我使用的IQueryable)。

and I have to marry this up with the repository somehow (or do I ??? as I read somewhere that the telerik engine takes care of this if I use IQueryable).

不幸的是,我得到一个异常之前控制器连打:

Unfortunately, I get an exception before the controller is even hit:

指定的方法不支持。

8号线:@(Html.Telerik()网格(模型)

Line 8: @(Html.Telerik().Grid(Model)

我可以张贴堆栈跟踪是否有帮助...

I can post the stacktrace if that helps ...

反正没人得到这个使用NHibernate,IQueryable的和ASP.NET MVC的工作(我实际使用锋利的架构2.0 RC)。

Anyway did someone get this to work using NHibernate, IQueryable and ASP.NET MVC (I am actually using sharp architecture 2.0 RC).

谢谢!

基督教

推荐答案

我只是这个昨天做。还有就是这方面的工作是Telerik的放在一起这是超级有用一个code样品:的http://www.telerik.com/community/$c$c-library/aspnet-mvc/grid/nhibernate-binding.aspx

I just did this yesterday. There is a code sample of this working that Telerik put together which was super useful: http://www.telerik.com/community/code-library/aspnet-mvc/grid/nhibernate-binding.aspx

几件事情要指出:


  • 您需要使用NHibernate的3.x的否则过滤将无法正常工作

  • 您不需要有分页code时,Telerik的gridcommand包含的信息,并将其插入到IQueryable的你

  • 这仅适用于客户端AJAX结合,这应该是这个样子:
    .DataBinding(数据绑定=方式&gt; dataBinding.Ajax()选择(指数,myController的))

  • 当你正在使用AJAX技术的结合,你将不需要模型传递到网格,而不是指定模式的类型,像这样: .Grid&LT; ItemRowViewModel&GT;()

  • You need to use Nhibernate 3.x. Otherwise filtering won't work
  • You don't need to have the paging code, The telerik gridcommand contains that info and plugs it into the IQueryable for you
  • This only works with a client side ajax binding, this should look something like: .DataBinding(dataBinding => dataBinding.Ajax().Select("index", "mycontroller"))
  • As you are using ajax binding you won't need to pass the model to the grid, instead you specify the type of model, like so: .Grid<ItemRowViewModel>()

它的工作超好,我在网格40万行。让我知道如果您有任何麻烦设置它。

It worked super well for me in a grid with 400,000 rows. Let me know if you have any trouble setting it up.

这篇关于Telerik的排序网格+ NHibernate的,IQueryable的和ASP.NET MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆