0

I have a grid and i am trying to bind data its working file if the number of records are less but for large records which in my case 3490 it fails to bind data

 $("#addCustomer_Admin").click(function () {
    debugger;
    $.ajax({
        url: '@Url.Action("GetAllUnAssignedUnits", "Admin")',
        dataType: "json",
        type: "POST",
        success: function (result) {
            debugger;
            BindUnitsGrid(result);
        },
        error: function (result) {
            debugger;

        }
    });
});

 function BindUnitsGrid(data) {
    debugger;
    $("#CustomerUnitsGrid").kendoGrid({
        dataSource: {
            data: data,
            schema: {
                model: {
                    fields: {
                        UnitID: { type: "number" },
                        Nickname: { type: "string" },
                        SerialNumber: { type: "string" },
                        UnitType: { type: "string" },
                        Address1: { type: "string" },
                        City: { type: "string" },
                        Region: { type: "string" },
                        PostalCode: { type: "string" }
                    }
                }
            },
            pageSize: 20,
        },

        sortable: true,
        filterable: true,
        columnMenu: true,
        pageable: true,
        columns: [
            { field: "UnitID", title: "UnitID" },
            { field: "Nickname", title: "Nickname" },
            { field: "SerialNumber", title: "SerialNumber" },
            { field: "UnitType", title: "UnitType" },
            { field: "Address1", title: "Address1" },
            { field: "City", title: "City" },
            { field: "Region", title: "Region" },
            { field: "PostalCode", title: "zip", hidden: true }
        ]
    });
}

and in my controller:

 [HttpPost]
    public async Task<ActionResult> GetAllUnAssignedUnits()
    {
        int UnKnownCutomerID = Convert.ToInt32(ConfigurationManager.AppSettings["UnknownCustomerID"]);
        if (Session["custUserID"] != null)
        {
            try
            {
                var list = await _unitRepo.GetUnassignedUnits(UnKnownCutomerID);
                return Json(list, JsonRequestBehavior.AllowGet);
            }
            catch (Exception exe)
            {
                Log objLog = new Log();
                objLog.LogError(exe.InnerException.ToString());
                return RedirectToAction("ShowError", "Error");
            }
        }
        else
        {
            return RedirectToAction("Index", "Account");
        }
    }

Is there any other way for this

Vivekh
  • 4,141
  • 11
  • 57
  • 102

1 Answers1

1

Yes, there are other options. I would definitely suggest server side paging for a large number of objects because that is a huge json array to manage. I would suggest the following post to implement server side paging.

How to implement Server side paging in Client side Kendo UI grid in asp.net mvc

Community
  • 1
  • 1
thispatchofsky
  • 854
  • 6
  • 15