系统返回json数据而不是使用asp.net mvc显示jqgrid

时间:2016-06-02 13:23:11

标签: jquery asp.net-mvc-4 jqgrid-asp.net

这里我添加了我在contoller中编写的代码以及视图。但是当我尝试使用http://localhost:portNumber/Campaign/Showcampaign进行调用时,系统仅显示json数据

这是我的控制器逻辑

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MailChimp.Lists;
using MailChimp;
using MailChimp.Api.Net.Services.Campaigns;

namespace AIO.Web.PO.Controllers
{
    public class CampaignController : Controller
    {
        // GET: Campaign
        public ActionResult Showcampaign()
        {
            MailChimpManager mc = new MailChimpManager("ee299c6cbb067a87aba659f3a0c21ca5-us13");
            return Json(mc.GetCampaigns().Data.ToArray(), JsonRequestBehavior.AllowGet);
        }
    }
}

这就是我在视图中编写代码的方式

@{
    ViewBag.Title = "Showcampaign";
}
<h2>Showcampaign</h2>
<div>
    <h2>My Grid Data</h2>
    <table id="list" class="scroll" cellpadding="0" cellspacing="0"></table>
    <div id="pager" class="scroll" style="text-align:center;"></div>
</div>
<script src="~/Scripts/jquery.jqGrid.js"></script>
<link href="~/Content/jquery.jqGrid/ui.jqgrid.css" rel="stylesheet" />
<link href="~/Content/themes/base/jquery-ui.css" rel="stylesheet" />
<script src="~/Scripts/grid.locale-en.js"></script>
<script src="~/Scripts/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
    $('#list').jqGrid({
        caption: "Campaign Details",
        url: '/Controllers/CampaignController/',
        datatype: "json",
        contentType: "application/json; charset-utf-8",
        mtype: 'GET',
        colNames: ['Subject', 'Id'],
        colModel: [
              { name: 'Subject', index: 'Subject', width: 150 },
              { name: 'Id', index: 'Id', width: 150 }
        ],
        rowNum: 10,
        loadonce: true

    });

</script>

这就是它

0 个答案:

没有答案