开发者

How to incrementally load data in mvccontrib grid in Asp.Net MVC2

I have a large data set and I want to load it incrementally so the user will have faster view loading开发者_高级运维.


You could implement pagination (using the AsPagination extension method from the MvcContrib.Pagination namespace):

public ActionResult Index()
{
    IEnumerable<MyViewModel> model = ... fetch from somewhere the dataset
    return View(model.AsPagination(1, 10));
}

and in your view:

@model IPagination<MyViewModel>
@(Html
    .Grid<MyViewModel>(Model)
    .Columns(columns =>
    {
        columns.For(x => x.Id);
        columns.For(x => x.Name);
    })
)
@Html.Pager(Model)

The documentation contains examples.


Or do it in Twitter way - get another portion when user scroll to the end of the page.


You can use ajax for loading the data as Dima metioned. If your user experience is extremely important, you may need to load 2 or 3 portions more. For example, the page loads the first two portions, and then loads next two portions when the user scrolls the end of portion 1. This could make the experience more smoother.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜