Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
Sort error jqgrid json
26/04/2011
20:09
Avatar
miki
Member
Members
Forum Posts: 12
Member Since:
20/04/2011
sp_UserOfflineSmall Offline

I am using jqgrid with json format. The grid is showing up wiyh data. I have enabled client side sorting using the following code

loadonce: true, // to enable sorting on client side

sortable:true //to enable sorting

When i try to sort IE is showing the Stop Running Script dialog saying "A script on this page is causing your web browser to run slowly. If it continues to run,   your computer might become unresponsive.".

I am using latest version of Jqgrid files. jquery-1.5.2.min.js, jquery.jqGrid.src.js, jquery.jqGrid.min.js.

What should I do to resolve this issue. Please help

Thanks

 My view:

<link href="../../css/custom-theme/jquery-ui-1.8.11.custom.css" rel="stylesheet" type="text/css" />
<link href="../../css/ui.jqgrid.css" rel="stylesheet" type="text/css" />

<script src="../../js/jquery-1.5.2.min.js" type="text/javascript"></script>
<script src="../../js/i18n/grid.locale-en.js" type="text/javascript"></script>
@*<script src="../../js/jquery.jqGrid.min.js" type="text/javascript"></script>*@
<script src="../../js/jquery.jqGrid.src.js" type="text/javascript"></script>

 <table id="list2"></table>
<div id="pager2"></div>

<script type="text/javascript">
    jQuery("#list2").jqGrid({
        url: '/Home/GetJQGridJsonData/',
        datatype: "json",
        colNames: ['AddressLine1', 'AddressLine2', 'City'],
        colModel: [
     { name: 'AddressLine1', index: 'AddressLine1', width: 100, sortable:true },
     { name: 'AddressLine2', index: 'AddressLine2', width: 100 },
     { name: 'City', index: 'City', width: 100 }

    ],
        rowNum: 20,
        rowList: [10, 20, 30],
        pager: '#pager2',
        sortname: 'AddressLine1',
        viewrecords: true,
        sortorder: "desc",
        caption: "Pilot Information",
        width: 800,
        height: 500,
        loadonce: true, // to enable sorting on client side
        sortable: true //to enable sorting
    });
    jQuery("#list2").jqGrid('navGrid', '#pager2', { edit: false, add: false, del: false });

</script>





 My cotroller:

        public virtual JsonResult GetJQGridJsonData(int page, int rows, string search, string sidx, string sord)
        {

            List<Address> jqData = new List<Address>();
            jqData = context.Addresses.ToList();

            int pageIndex = Convert.ToInt32(page) - 1;
            int pageSize = rows;
            int totalRecords = jqData.Count();

            int totalPages;
            if (totalRecords > 0)
                totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);
            else
                totalPages = 0;

            // if for some reasons the requested page is greater than the total set the requested page to total page
            if (page > totalPages) page = totalPages;

            //total - Total number of Pages.
            //page - Current page Index.
            //records - Total number of records in the rows group.
            //rows - An array with the data plus an identifier.
            //id - The unique row identifier, needs to be an int from what I have found.
            //cell - An array of the data for the grid.
            var jsonData = new JqGridJsonData
            {

                total = totalPages,
                page = pageIndex,
                records = totalRecords,

                rows = jqData.Select(vm =>
                             new JQGridRowJson
                             {
                                 id = vm.AddressLine1,
                                 cell = new[]{
                                               
                                                   vm.AddressLine1,
                                                   vm.AddressLine2,
                                                   vm.City,
                                                   vm.PostalCode
                                }
                             }).ToArray()

            };
            return Json(jsonData, JsonRequestBehavior.AllowGet);
        }

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
19 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information