Asp.net 如何将json格式的数据从JsonResult传递到JQGrid?求求你,我需要帮助,我陷入这个问题好几天了。我再次提出这个问题

Asp.net 如何将json格式的数据从JsonResult传递到JQGrid?求求你,我需要帮助,我陷入这个问题好几天了。我再次提出这个问题,asp.net,json,asp.net-mvc,jqgrid,jqgrid-asp.net,Asp.net,Json,Asp.net Mvc,Jqgrid,Jqgrid Asp.net,我试图将数据从控制器传递到GQ网格。我已经实现了SQL操作——在另一个文件中选择一行,并将列表类型为list的对象返回给控制器。我实现了JsonResult类型的控制器,它以json格式返回数据。控制器正在使用[HttpGet]属性。我已经附上了我的控制器代码,html,js文件和问题的截图。谷歌控制台没有显示任何问题。表正在准备就绪,但表数据正在显示。我想“传递数据”是有问题的。如果有人能检查我的代码,让我知道哪里出了错,那对我会很有帮助。 我的数据库由一行和两列组成,分别是:Name和Ema

我试图将数据从控制器传递到GQ网格。我已经实现了SQL操作——在另一个文件中选择一行,并将列表类型为
list
的对象返回给控制器。我实现了
JsonResult
类型的控制器,它以json格式返回数据。控制器正在使用
[HttpGet]
属性。我已经附上了我的控制器代码,html,js文件和问题的截图。谷歌控制台没有显示任何问题。表正在准备就绪,但表数据正在显示。我想“传递数据”是有问题的。如果有人能检查我的代码,让我知道哪里出了错,那对我会很有帮助。 我的数据库由一行和两列组成,分别是:Name和Email。另外,我想在第三行添加编辑按钮

此外,是否有任何软件,我可以在连接到服务器时检查问题出在哪里,因为在这种情况下,Google inspect工具根本没有帮助

在我的控制器中,通过使用断点,我检查了
Integrations value=db.GetIntegrationRow()中的值我在
中得到了正确的值。 控制器:

#region Namespace

using MCNIDev.DBAccess;
using MCNIDev.Models.ViewModel;
using MCNIDev.Processor.Services;

using System.Web.Mvc;

#endregion

namespace MCNIDev.Content
{
    /// <summary>
    /// This controller class is responsible for all action in  Integration view
    /// </summary>
    public class IntegrationsController : Controller
    {
        public ActionResult Details()
        {
            return PartialView();
        }

        /// <summary>
        /// To get the data for JQGrid
        /// </summary>
        [HttpGet]
        public JsonResult Detail()
        {

            IntegrationsProcessor db = new IntegrationsProcessor(new MCNIDbContext());
            Integrations value = db.GetIntegrationRow();

            return new JsonResult()
            {
                               Data = value,
                               JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };
           
        }

    }
}
#区域名称空间
使用MCNIDev.DBAccess;
使用MCNIDev.Models.ViewModel;
使用MCNIDev.Processor.Services;
使用System.Web.Mvc;
#端区
名称空间MCNIDev.Content
{
/// 
///此控制器类负责集成视图中的所有操作
/// 
公共类集成控制器:控制器
{
公众行动结果详情()
{
返回PartialView();
}
/// 
///获取JQGrid的数据
/// 
[HttpGet]
公共JsonResult详细信息()
{
IntegrationsProcessor db=新的IntegrationsProcessor(新的MCNIDbContext());
集成值=db.GetIntegrationRow();
返回新的JsonResult()
{
数据=值,
JsonRequestBehavior=JsonRequestBehavior.AllowGet
};
}
}
}
HTML文件

@using MCNIDev.CustomControls
@model MCNIDev.Models.ViewModel.Integrations


@{
    ViewBag.Title = "Details";
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=devicexb c-width" />
    <title>Integrations</title>
</head>
@Styles.Render("~/Content/toasterCss")
@Styles.Render("~/Content/dataPickerCss")
<style type="text/css">
    .btn {
        min-width: 80px !important;
    }
</style>
<body>
    @using (Html.BeginForm("", "Integrations", FormMethod.Post, new { enctype = "multipart/form-data", @class = "form-horizontal", id = "frmManifestOrders" }))
    {
        <div class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1 class="m-0 text-dark">Integrations</h1>
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.container-fluid -->
        </div><!-- /.content-header -->

        <section class="content">
            <div class="container-fluid">
                <div class="card card-block">
                    <div class="row table-responsive">
                        <div class="col-md-12">
                            <div class="row">
                                <div class="col-md-12 col-sm-12">
                                    <table id="tblSelectIntegrations"></table>
                                    <div id="divSelect"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12">
                            <div class="row">
                                <div class="col-md-12">
                                    <hr />
                                    <input type="button" class="btn btn-secondary" onclick="document.location.href='/Dashboard/Dashboard';" value="Cancel" />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    }
</body>
</html>
@*Bundle file includes the path to single JavaScript file Integration that does GQGrid operation *@
@Scripts.Render("~/bundles/integrations")
<script>
$(document).ready(function(){
    Integrate.GetValue();
});
</script>
@使用MCNIDev.CustomControls
@模型MCNIDev.Models.ViewModel.Integrations
@{
ViewBag.Title=“详细信息”;
}
整合
@Styles.Render(“~/Content/toasterCss”)
@style.Render(“~/Content/dataPickerCss”)
.btn{
最小宽度:80px!重要;
}
@使用(Html.BeginForm(“,”Integrations“,”FormMethod.Post,new{enctype=“multipart/formdata”,@class=“form horizontal”,id=“frmManifestOrders”}))
{
整合

} @*捆绑文件包括执行GQGrid操作的单个JavaScript文件集成的路径*@ @Scripts.Render(“~/bundles/integrations”) $(文档).ready(函数(){ Integrate.GetValue(); });
JavaScript文件:

var Integrate = function() {
function GetValue() {
    $("#tblSelectIntegrations").jqGrid({
        mtype: "GET",
        url: "/Integrations/Detail",
        datatype: "json",
        async: false,
        colNames: [
            "First Name", "Email Address",""
        ],
        colModel: [
            //{
            //    name: '',
            //    key: false,
            //    width: 30,
            //    editable: true,
            //    formatter: function () {
            //        return "<input type='checkbox' value='Select' class='fm-button ui-state-default ui-corner-all fm-button-icon-left noPrint'\>";
            //    }
            //},
            { key: false, name: 'IntegrationName', index: 'IntegrationName', editable: false, width: 200 },
            { key: false, name: 'CompanyEmail', index: 'CompanyEmail', editable: false, width: 200 },
         { key: false, name: 'Blank', index: 'Blank', editable: false, width: 200 }
        ],
        pager: jQuery("#divSelect"),
        rowNum: 1,
        scroll: 0,
        height: $(window).innerHeight() - 450,
        width: "100%",
        viewrecords: true,
        caption: "Product",
        emptyrecords: "No records to display",
        jsonReader: {
            root: "",
            page: "page",
            total: "total",
            records: "records",
            repeatitems: false
        },
        autowidth: true,
        multiselect: false,
        loadonce: false,
        ajaxGridOptions: { cache: false },
              
    }).navGrid("tblSelectIntegrations", { edit: false, add: false, del: false, search: false, refresh: false });
}
return {
        GetValue: GetValue
    };
}();
var Integrate=function(){
函数GetValue(){
$(“#tblselectionintegrations”).jqGrid({
mtype:“获取”,
url:“/Integrations/Detail”,
数据类型:“json”,
async:false,
姓名:[
“名字”、“电子邮件地址”
],
colModel:[
//{
//名称:“”,
//关键:错,
//宽度:30,
//是的,
//格式化程序:函数(){
//返回“”;
//    }
//},
{key:false,name:'IntegrationName',index:'IntegrationName',可编辑:false,宽度:200},
{键:false,名称:'CompanyEmail',索引:'CompanyEmail',可编辑:false,宽度:200},
{键:false,名称:'Blank',索引:'Blank',可编辑:false,宽度:200}
],
寻呼机:jQuery(“#divSelect”),
rowNum:1,
滚动:0,
高度:$(窗口).innerHeight()-450,
宽度:“100%”,
viewrecords:是的,
标题:“产品”,
emptyrecords:“没有要显示的记录”,
jsonReader:{
根:“,
第页:“第页”,
总计:“总计”,
记录:“记录”,
重复项:false
},
自动宽度:正确,
多选:错,
loadonce:false,
ajaxGridOptions:{cache:false},
}).navGrid(“tblSelectIntegrations”,{edit:false,add:false,del:false,search:false,refresh:false});
}
返回{
GetValue:GetValue
};
}();
这是我得到的截图: