NO URL设置 - 错误的jqGrid(添加,删除对话框)

问题描述:

我下面的网格显示数据,现在当我要添加新的记录它给了“NO网址设为”NO URL设置 - 错误的jqGrid(添加,删除对话框)

$(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(),但它给出了同样的错误'NO URL IS SET'在添加记录或删除记录对话框上提交数据的时间。

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

+0

嗯,很好,我明白了,谢谢:) – 2012-03-27 13:15:31

+1

@ITppl:不客气!这样的事情很简单,如果另一个人看你的代码,但如果一个人寻找原因,可能需要很长时间才能找到原因。 :-) – Oleg 2012-03-27 13:23:07

+0

yupp,这是真的.. :) – 2012-03-27 13:24:58