0

Recently, I have started getting an issue related to "SystemOutOfMemoryException" in free-jQgrid. The version that I am using is 4.15.4 with MVC 5 and Sql Server DB queries for bringing data . The reason I have found is growth of the data. If data is around 10K with LoadOnce:true at that point it works without any issue. But when more data comes then it started throwing this issue. I am getting all data from database in one go and loads it to the grid.

Here is some pieces of controller code:

        public JsonResult GetDataWRTLanguage(string searchKey)
        {

            FormBL formsbl = new FormBL();
            List<Form_Check> lstPPVM = new List<Form_Check>();
            filter f = new filter();
            string returnedLangCode = "";

            if (searchKey != "")
            {
                TempData["LanguageCode"] = searchKey;
            }

            if (Convert.ToString(TempData["LanguageCode"]) != "")
            {
                returnedLangCode = Convert.ToString(TempData["LanguageCode"]);
                TempData.Keep("LanguageCode");
            }
            else{
                returnedLangCode = searchKey;                
            }


            lstPPVM = formsbl.getDataWithLanguage(returnedLangCode);
            //var newList = JsonConvert.SerializeObject(lstPPVM);
            int page = 1, rows = 1;
            int pageIndex = Convert.ToInt32(page) - 1;
            int pageSize = rows;
            int totalRecords = lstPPVM.Count();
            var totalPages = (int)Math.Ceiling((float)totalRecords / (float)rows);
            var Results = lstPPVM.AsQueryable();
            var jsonData = new
            {
                total = totalPages,
                page = page,
                records = totalRecords,
                rows = Results
            };
            var jsonResult = Json(jsonData, JsonRequestBehavior.AllowGet);
            jsonResult.MaxJsonLength = int.MaxValue;
            return jsonResult;
        }

Here is jqgrid code

    $("#grid").jqGrid({
            url: '/MView/GetDataWRTLanguage?searchKey=' + LanguageId + "",
            mtype: "GET",
            datatype: "json",
            colNames: [*more than 15*]
            colModel: [*body of all columns with search*]
            loadComplete: function () {                
                if ($('#grid').getGridParam('records') === 0) {
                    oldGrid = $('#GridIdb2 tbody').html();
                    $(".jqgfirstrow").css("height", "1px");                   
                }
                else {
                    oldGrid = "";
                }
                this.p.lastSelected = lastSelected; 
                var obj = JSON.parse(sessionStorage.getItem('majorgridInfo'));
                if (obj != undefined || obj != undefined || obj != null || obj != null) {
                    jQuery("#grid").setGridParam({ rowNum: obj.rowNum.toString() });
                    var grid = $("#grid");
                    jQuery("#grid").setGridParam({ rowNum: obj.rowNum }).trigger("reloadGrid");
                    $('.ui-pg-selbox').val(obj.rowNum);
                }
            },
            onPaging: function (pgbtn) {
                Selected_RowList = $('.ui-pg-selbox').val();
                saveGridParameters();
            },
            forceClientSorting: true,
            cmTemplate: { autoResizable: true },
            width: '100%',
            scrollbar: true,
            autoResizing: { compact: true },
            editurl: "/MajorsView/EditParticipantRecords/",
            pager: jQuery('#pager'),
            loadonce: true,
            viewrecords: true,
            gridview: true,
            height: '480px',
            //width: '100%',
            //maxHeight: 980,
            //pager: '#pager',
            rowNum: 25,     //// adjust height of Jqgrid
            rowList: [25, 100, 200, 500, 1000,10000],       ////adjust height of Jqgrid
            ignoreCase: true,
            autowidth: true,
            shrinkToFit: false,
            hidegrid: true, //To disable collapsing
            iconSet: "fontAwesome",
            caption: "<i class='fa fa-users'></i> Participant List",
            multiSort: true,
            sortname: 'ReferenceId',
            sortOrder: 'asc',
            rowattr: function (rd) {
                if (rd.Check === "true") { 
                    return { "class": "state_inactive" };
                }
            },

            multiselect: false,
            emptyrecords: "No records to display",
            jsonReader:
            {
                root: "rows",
                page: "page",
                total: "total",
                records: "records",
                repeatitems: false,
                Id: "ReferenceId"
            },
            inlineEditing: { keys: true, defaultFocusField: "ReferenceId", focusField: "ReferenceId" },
          });

Here I also used JsonMaxLength property but it still throws error. I've seen that even 60K data is still working fine with it but for me it starts giving error on more than 10K data.

Additional questions: Should I use Server side jqgrid implementation, if yes then how can i modify this link to newer version of MVC and jQgrid version.

Any help would be greatly appreciated.

Chandan
  • 217
  • 1
  • 3
  • 17
  • 1
    There are a lot of posts regarding server side pagination in jqGrid. You can search the web too. By example [this one](https://moinulmithu.wordpress.com/2016/04/01/jqgrid-with-asp-net-mvc-5-application/) – Tony Tomov Dec 04 '19 at 16:41
  • Hello and Thanks Tony for taking time to provide your input. Glad to e-meet you. Yes, I have searched web for the same and ended up getting jquery-jqgrid or jquerygrid related examples. Which I thought not matching with free-jqgrid. Though, I read Oleg's post about server side pagination in free-jqgrid but it is bit old now. So, thought to ask here. Another thing, I wanted to know why the error is throwing in the free-jQgrid. – Chandan Dec 04 '19 at 16:53

0 Answers0