2012-03-21 52 views
0

我有一個JQGrid,它在加載時工作正常。但我想發送一些額外的數據到一個wcf服務。我試過editData,Serializeeditdata但無法做到這一點。任何人都可以幫助我發送它。我搜索並嘗試了很多並且實施,但它沒用。如果我爲我的保存方法添加參數jqgrid拋出錯誤。JQGrid在編輯期間發佈數據

jQuery(document).ready(function() { 
      jQuery("#grid").jqGrid({ 
       url: "../Service.svc/GetData", 
       data: JSON.stringify(params),`enter code here` 
       dataType: "json", 
       type: "POST", 
       contentType: "application/json; charset=utf-8", 
       colNames: ['Id', 'Value'], 
       colModel: [{ name: 'Id', index: 'Id', width: 1, align: 'left', editable: false}, 
         { name: 'Value', index: 'Value', width: 270, align: 'left', editable: true}, 
         ],     
       pager: jQuery('#pageNavigation'),    
       editurl: "../Service.svc/SaveData", 
       loadError: ShowError 
      }).navGrid('#pageNavigation', { edit: true, add: true, del: true, search: false }, //options 
       {// edit options 
       editData: {firstName: 'Test'}, 
       height: 100, width: 230, reloadAfterSubmit: true, closeOnEscape: true 
      } 
     }); 

// WCF CODE

<WebInvoke(Method:="POST", BodyStyle:=WebMessageBodyStyle.WrappedRequest, ResponseFormat:=WebMessageFormat.Json)> 
     Public Function GetData As String Implements Iservice.GetData 
     End Function 

     Public Sub SaveData(ByVal firstName As String) Implements Iservice.SaveData 
     //Retreive name and Do Some operation 
     End Sub 

回答

0

難道你還需要一個<WebInvoke>屬性裝飾你的SaveData方法?你有這個,它不是你提供的代碼的一部分?否則,您需要提供,以便您的方法可以作爲WCF調用訪問。

<WebInvoke(Method:="POST", BodyStyle:="...", ...)> 
Public Sub SaveData(ByVal firstName As String) Implements Iservice.SaveData 
//Retreive name and Do Some operation 
End Sub 
+0

我把它作爲我在這裏提到。它不斷給我錯誤狀態:內部服務器錯誤錯誤代碼:500.不知道如何解決這個問題。 – 2012-03-22 13:09:32

+0

你是否能夠瀏覽你的代碼?聽起來就像你在SaveData方法的某個地方有錯誤。 – 2012-03-22 13:41:39

+0

它甚至沒有進入functin。我可以通過get方法並調試它。但在這裏,只要我點擊提交按鈕,它就會給我這個錯誤。 – 2012-03-22 14:32:15