This project is read-only.

Paging on the grid…..

Mar 10, 2014 at 8:03 PM
Edited Mar 10, 2014 at 8:50 PM
Hi my model returns 2,000,000 records which are need to be shown on the grid. So I am using Iqueryable and skip and take as the result I can display only the required data on the grid. By doing so I can’t see the paging(Displayed Pages) on the grid how to retrieve that data.
Sample code:
    public ActionResult Index()
        IQueryable<TRAN_LOG> tranLog = null;
        int pageCount = 25;
        CDSDataModel ctx = new CDSDataModel();
        var count = Request.QueryString["grid-page"];
        int rowIndex = Request.QueryString["grid-page"] == null ? 0 :              (Convert.ToInt32(Request.QueryString["grid-page"]) - 1) * pageCount;

            tranLog = (from a in ctx.TRAN_LOGs
                       orderby a.TRAN_LOG_TS descending
                       select a).Skip(rowIndex).Take(pageCount);
        return View(tranLog);

On the view:
    columns.Add(value=>value.TRAN_LOG_ID).Titled("Tran Log ID").SetWidth(100);
    columns.Add(value=>value.TRAN_LOG_TS).Titled("Tran Log TS").SetWidth(100);
    columns.Add(value=>value.TRAN_LOG_LEVEL).Titled("Tran Log Level").SetWidth(100);
    columns.Add(value=>value.TRAN_LOG_MSG).Titled("Tran Log Message").SetWidth(100);
    columns.Add(value=>value.TRAN_LOG_EXCPT).Titled("Tran Log EXCPT").SetWidth(100);
        columns.Add(value=>value.TRAN_LOG_HOST_NAME).Titled("Tran Log Host Name").SetWidth(100);
    columns.Add(value=>value.TRAN_LOG_UNIQUE_ID).Titled("Tran Log Unique ID").SetWidth(100);
[1][2][3].....[35] --> is missing on the view
Mar 12, 2014 at 4:05 AM

You can pass IQueryable directly to the grid, grid will invoke Skip().Take() for you:
return View(ctx.TRAN_LOGs);