Solved

Display data in jqGrid Footer row in MVC2 Application

Posted on 2010-08-17
1
3,552 Views
Last Modified: 2013-11-08
I need help display data in the jqGrid footer row. This is my configuration on the Server and below it is my HTML code Notice the userdata = (Hours) line.

The userData amount that I need displayed in the footer is coming through in the JSON. I am using Fiddler to view it. Here is a screenshot of the fiddler view:

I need to display this value of "12" in the footer. This the HTML I am using to read the JSON:
SERVER:



// Format the data for the jqGrid

        var jsonData = new

        {

            total = totalPages,

            page = page,

            records = totalRecords,                                 

            rows = (

                  from a in activities

                  select new

                  {

                      id = a.ActivityId,

                      cell = new string[] {

                      a.ActivityId.ToString(),                          

                      DateTime.Parse(a.Date.ToString()).ToShortDateString(),                          

                      a.Person.Name.ToString(),

                      a.ActivityName.ToString(),

                      a.Hours.ToString()                          

                    }

                  }).ToArray(),

            userdata = (Hours)

        };



        // Return the result in json

        return Json(jsonData, JsonRequestBehavior.AllowGet);



HTML:

jQuery("#list").jqGrid({

        url: gridDataUrl + '?startDate=' + startDate.toJSONString() + '&endDate=' + endDate.toJSONString(),

        datatype: "json",

        mtype: 'GET',

        colNames: ['Activity ID', 'Date', 'Employee Name', 'Activity', 'Hours'],

        colModel: [

          { name: 'ActivityId', index: 'ActivityId', width: 40, align: 'left' },

          { name: 'Date', index: 'Date', width: 50, align: 'left' },

          { name: 'Person.Name', index: 'Person.Name', width: 100, align: 'left', resizable: true },

          { name: 'ActivityName', index: 'ActivityName', width: 100, align: 'left', resizable: true },

          { name: 'Hours', index: 'Hours', width: 40, align: 'left' }

          ],

        loadtext: 'Loading Activities...',

        multiselect: true,

        rowNum: 20,

        rowList: [10, 20, 30],

        imgpath: gridimgpath,

        height: 'auto',

        width: '700',

        pager: jQuery('#pager'),

        sortname: 'ActivityId',

        viewrecords: true,

        sortorder: "desc",

        caption: "Activities",

        footerrow: true, userDataOnFooter: true, altRows: true       

    }).navGrid('#pager', { search: true, edit: false, add: false, del: false, searchtext: "Search Activities" });

Open in new window

JSON.jpg
0
Comment
Question by:obautista
1 Comment
 

Accepted Solution

by:
obautista earned 0 total points
Comment Utility
This was the solution:

then the userdata part of the JSON data is:

  "userdata":{"Hours":12}

var jsonData = new {
    total = totalPages,
    page = page,
    records = totalRecords,
    rows = (
        from a in activities
        select new {
            id = a.ActivityId,
            cell = new string[] {
                a.ActivityId.ToString(),
                DateTime.Parse(a.Date.ToString()).ToShortDateString(),
                a.Person.Name.ToString(),
                a.ActivityName.ToString(),
                a.Hours.ToString()
            }
        }).ToArray(),
        userdata = new {
            Hours = 12
        }
    };

Open in new window

0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now