NO URL IS SET - jqGrid中的错误(添加,删除对话框)

时间:2012-03-27 13:01:02

标签: jqgrid jqgrid-asp.net

我跟着网格显示数据,现在当我想添加新记录时,它会给出错误'NO URL IS SET'

$(document).ready(function () {
        $('#PRGrid').jqGrid({
            //url from wich data should be requested
            url: '@Url.Action("BindData")?FillType=' + getFillType(),
            //event for inline edit
            onSelectRow: function (currentSelectedRow) {
                if (currentSelectedRow && currentSelectedRow != $.lastSelectedRow) {
                    //save changes in row 
                    $('#PRGrid').jqGrid('saveRow', $.lastSelectedRow, false);
                    $.lastSelectedRow = currentSelectedRow;
                }
                //trigger inline edit for row
            },
            //type of data
            datatype: 'json',
            //url access method type
            mtype: 'POST',
            //columns names
            colNames: ['Code', 'Name', 'No_Rooms', 'Dept_Code', 'Total_Items'],
            //columns model
            colModel: [
                        {   name: 'Code', index: 'Code', align: 'left', width: '120px', editable: true, edittype: 'select', editoptions: { maxlength: 25, dataUrl: '@Url.Action("GetRooms")',
                            dataEvents: [{ 
                                type: 'change', fn: function (e) {
                                var ret = $.ajax({
                                url: '@Url.Action("selectRoom")?id=' + $(this).val(),
                                async: false,
                                success: function (ret) {
                                    $('#Name').val(ret.Name);
                                    $('#No_Rooms').val(ret.qty);
                                    $('#Dept_Code').val(ret.DeptCode);
                                    $('#Total_Items').val(ret.Total_Items);}
                                });}
                            }]
                        }},
                        { name: 'Name', index: 'Name', align: 'left', formatter: "text", width: '185px', editable: true, editrules: { required: true }, editoptions: { readonly: 'readonly'} },
                        { name: 'No_Rooms', index: 'No_Rooms', align: 'left', formatter: "text", width: '102px', integer: true, editable: true, editrules: { required: true }, editoptions: { readonly: 'readonly'} },
                        { name: 'Dept_Code', index: 'Dept_Code', align: 'left', formatter: "text", width: '78px', editable: true, editrules: { required: true }, editoptions: { readonly: 'readonly'} },
                        { name: 'Total_Items', index: 'Total_Items', align: 'left', formatter: "text", width: '82px', integer: true, editable: true, editrules: { required: true }, editoptions: { readonly: 'readonly'} },
                    ],
            //pager for grid            
            pager: $('#PRGridPager'),
            //number of rows per page
            rowNum: 5,
            //initial sorting column
            sortname: 'Code',
            //initial sorting direction
            sortorder: 'asc',
            recreateForm:true,
            //we want to display total records count
            viewrecords: true,
            //grid height
            height: '100%'
        });

        $('#PRGrid').jqGrid('navGrid', '#PRGridPager',
                { add: true, del: true, edit:false, search: true },
                {width: '330', url:'@Url.Action("InsertPRGridRecord")', closeAfterAdd: true },
                {width: '330', url:'@Url.Action("DeleteGridRecord")'});

        var dialogPosition = $(this).offset();

当我想在网格中添加或删除记录时出现问题

这里我已经定义了InsertPRGridRecord()和DeleteGridRecord()方法,但是在Add Record或Delete Record对话框中提交数据时它给出了同样的错误'NO URL IS SET'。

1 个答案:

答案 0 :(得分:1)

我认为问题的存在是因为您使用navGrid的参数不正确。您当前的代码使用'@Url.Action("DeleteGridRecord")'作为“添加”的网址,使用'@Url.Action("InsertPRGridRecord")'作为“编辑”的网址。未指定“删除”的网址。