【问题标题】:jqgrid not working with viewmodel but worked with modeljqgrid 不与 viewmodel 一起使用,但与 model 一起使用
【发布时间】:2019-02-21 00:36:24
【问题描述】:

我正在尝试修改和现有的 jqGrid,它通过 C# MVC 中的模型显示数据,但我不能只显示来自一个模型的数据,我必须从多个模型中检索和显示数据,所以我使用视图模型而不是模型,但没有填充数据。

之前: createReferralGrid = function (parentRowId, referrals, studentId, testDate) {

    $grid.jqGrid({
        sg_blankRowOnAdd: !_readOnly,
        sg_blankRowData: blankRow,
        cmTemplate: { sortable: false, title: false, fixed: true },
        data: referrals,............
         colModel: [
            {
                name: 'ReferralCode',
                index: 'ReferralCode',
                width: 105,
                formatter: function (cellvalue, options, rowObject)

之后: createReferralGrid = function (parentRowId, rowData, studentId, testDate) {

    $grid.jqGrid({
        sg_blankRowOnAdd: !_readOnly,
        sg_blankRowData: blankRow,
        cmTemplate: { sortable: false, title: false, fixed: true },
        data: rowData,
        datatype: "local",
        height: "auto",....  


        colModel: [
            {
                name: 'Referrals.ReferralCode',
                index: 'Referrals.ReferralCode',
                width: 105,
                formatter: function (cellvalue, options, rowObject)

注意:Referrals 是 rowData 中的一个模型,之前我只传递了引荐,所以它可以工作,但现在我传递了 viewmodel(rowData),我在 colModel 中使用了 rowData.ReferralCode,然后它就不起作用了

【问题讨论】:

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


    【解决方案1】:

    你能展示你的视图模型代码吗?问题可能是正确使用模型制作relation 你需要知道

    一对一关系

    一对多

    多对多关系

    这对你有帮助吗

    【讨论】:

    • 公开课 StudentExamGridViewModel { public BaseStudentMedicalExamModel 考试 { get;放; } 公共字符串名称 { 获取;放; } 公共字符串 注意 { 获取;放; } public List 推荐人 { get;放; } public List ReferralStateCommons { get;放; } ******************************************* hmp.me/cadr *** ******************************* 我在 jquery 中获取数据,但无法通过 jqgrid 显示。添加了调试模式的截图
    【解决方案2】:

    经过大量搜索后,我发现我们无法访问 jqgrid 中的视图模型,我们只需将模型传递给 jqgrid 或其他包含直接值而不是嵌套格式的数据源。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-20
      • 1970-01-01
      • 1970-01-01
      • 2020-03-28
      相关资源
      最近更新 更多