代码之家  ›  专栏  ›  技术社区  ›  LeftyX

jqGrid与后置动词

  •  0
  • LeftyX  · 技术社区  · 14 年前

    今天我试着在ASP.NETMVC2项目中实现它,但效果并没有达到预期的效果。
    如果我强制控制器支持GET-forcing JSON响应,如下所示:

    return(Json(value, JsonRequestBehavior.AllowGet))
    

    ... 并具体说明

    [AcceptVerbs( HttpVerbs.Get )]
    

    方法论

    一切正常,我的jqGrid显示了结果。 我试着改变jqGrid的动词 myType:'发布' 但是电网停止工作了。
    我做了一点调试和跟踪,似乎jqGrid从未发布请求。 我的控制器总是收到GET。

    谢谢

    阿尔贝托

    样品:

    jQuery("#ProvincesDynamicGrid").jqGrid({
        url: '<%=Url.Action("Fetch", "Provinces")%>',
        postData: { id: '0' },
        datatype: 'json',
        myType: 'POST',
        colNames: ['Descr', 'Prov', 'Regione'],
        colModel: [{ name: 'Description', index: 'Description', editable: false, resizable: true, sortable: false, width: 200, align: 'right' },
                   { name: 'Initial', index: 'Initial', editable: true, editrules: { required: true, custom: true, custom_func: ValidateInitialColum }, resizable: true, sortable: false, width: 90, align: 'right' },
                   { name: 'RegionDescription', index: 'RegionDescription', editable: false, resizable: true, sortable: false, width: 200, align: 'right' }
                  ],
        pager: $('#ProvincesDynamicPager'),
        rowNum: 11,
        // rowList: [10, 20, 50],
        width: 748,
        height: 253,
        viewrecords: true,
        shrinkToFit: false,
        scroll: false,
        rownumbers: true,
        hidegrid: false,
        caption: 'Gestione Province',
        cellEdit: true,
        cellsubmit: 'remote',
        cellurl: '<%=Url.Action("SaveProvince", "Provinces")%>',
        onSelectRow: function(id) {
            SelectedRowId = id;
        },
        beforeSaveCell: function(rowid, cellname, value, iRow, iCol) {
    
        },
        afterSubmitCell: function(serverresponse, rowid, cellname, value, iRow, iCol) {
            var resp = jQuery.parseJSON(serverresponse.responseText);
            // if (resp.Status == false)
            return ([resp.Status, resp.Message])
            //alert(resp.Message);
        }
    });
    
    1 回复  |  直到 14 年前
        1
  •  1
  •   LeftyX    14 年前

    正如Tony在jqGrid论坛上所说的那样,我错把 参数(myType:'POST') 所以确切的代码是这样的:

    jQuery("#ProvincesDynamicGrid").jqGrid({
        url: '<%=Url.Action("Fetch", "Provinces")%>',
        postData: { id: '0' },
        datatype: 'json',
        mtype: 'POST',
        colNames: ['Descr', 'Prov', 'Regione'],
        colModel: [{ name: 'Description', index: 'Description', editable: false, resizable: true, sortable: false, width: 200, align: 'right' },
                   { name: 'Initial', index: 'Initial', editable: true, editrules: { required: true, custom: true, custom_func: ValidateInitialColum }, resizable: true, sortable: false, width: 90, align: 'right' },
                   { name: 'RegionDescription', index: 'RegionDescription', editable: false, resizable: true, sortable: false, width: 200, align: 'right' }
                  ],
        pager: $('#ProvincesDynamicPager'),
        rowNum: 11,
    ...