在MVC应用程序的jqGrid页脚行中显示数据 [英] Display data in jqGrid Footer row in MVC Application

查看:90
本文介绍了在MVC应用程序的jqGrid页脚行中显示数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助在jqGrid页脚行中显示数据.这是我在服务器上的配置.请注意 userdata =(小时)行.

I need help display data in the jqGrid footer row. This is my configuration on the Server. Notice the userdata = (Hours) line.

// 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);

我需要在页脚中显示的userData数量通过JSON传递.我正在使用Fiddler进行查看.这是提琴手视图的屏幕截图:

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:

替代文字http://shirey.technologyblends.com/Content/images/json .jpg

我需要在页脚中显示此值"12" .这是我用来读取JSON的HTML:

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

        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" });

推荐答案

尝试使用以下内容

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
        }
    };

然后JSON数据的userdata部分将为

then the userdata part of the JSON data will be

  "userdata":{"Hours":12}

接下来是在jqGrid表的页脚部分的列Hours中显示粗体值12.

which follows to displaying of the bold value 12 in the column Hours of the footer part of the jqGrid table.

这篇关于在MVC应用程序的jqGrid页脚行中显示数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆