通过分页,过滤和搜索进行服务器端处理的数据表 [英] Datatable for server side processing with paging, filtering and search

查看:91
本文介绍了通过分页,过滤和搜索进行服务器端处理的数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为我的asp使用jquery数据表服务器端处理( http://datatables.net ).net(C#)网站.

I need to use the jquery datatable server-side processing (http://datatables.net) for my asp.net (C#) Web-Site.

我的网站有成千上万条记录,以列表的形式显示在表中.我正在服务器端使用jquery数据表来启用分页,过滤和搜索.

My Web-Site has thousands of records to show in the table as list. I am using jquery datatable server-side to enable paging, filtering and search.

对于与asp.net(C#)一起使用的jquery数据表服务器端处理,是否有很好的参考/文章?

Is there any good reference/articles for jquery datatable server-side processing to use with asp.net (C#)?

推荐答案

发送到控制器的参数和需要返回的值在此处

The parameters sent to your controller and the values you need to return are defined in the docs here http://datatables.net/manual/server-side

使用如下签名设置您的.net终结点:

Set up your .net endpoint with a signature like so:

public JsonResult GetResultDtData(
        int draw, 
        int start, 
        int length,
        Dictionary<string, string> search, 
        List<Dictionary<string,string>> order, 
        List<Dictionary<string, string>> )

然后,您可以使用这些参数来确定需要发送回哪些数据.可以使用Skip()和Take()进行分页

Then you can use those parameters to decide on what data you need to send back. Paging can be done with Skip() and Take()

IEnumerable theDataToReturn = GetMyDataFromDB();
DataTablesReturnData dtReturn = new DataTablesReturnData()
{
  draw = draw,
  recordsTotal = theDataToReturn.Count,
  recordsFiltered = theDataToReturn.Count,
  data = getData().Skip(start).Take(length).ToList()
};

return dtReturn;

过滤和排序有点复杂,但是您需要的所有信息都存储在初始参数(搜索,排序和列)中.

Filtering and ordering are a bit more complex, but all the info you need is stored in the initial parameters (search, order and columns).

这篇关于通过分页,过滤和搜索进行服务器端处理的数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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