jQuery/jqGridは初めてです。asmx Webサービスからjson形式のデータを返し、そのデータをjqGridに表示したいと思います。グリッドはページ上にレンダリングされていますが、データの行が含まれていません。jqGridが探している正しい形式を返しているかどうかはわかりません。または私が何か他のものを逃している場合。
(このトピックに関連するSOに関する多くの質問に出くわしたので、これがすでに回答されている場合は事前に謝罪します。現時点では、利用可能なさまざまな回答の数でさえ、さらに混乱を引き起こしています)。
ウェブサービス
<System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class WebService1
Inherits System.Web.Services.WebService
Public Class Person
Public FirstName As String
Public LastName As String
End Class
<WebMethod()>
<ScriptMethod(UseHttpGet:=False, ResponseFormat:=ResponseFormat.Json)> _
Public Function GetPersonList() As List(Of Person)
Dim personList As New List(Of Person)
'Connect to DB
'While reading from DB
personList.Add(
New Person() With {
.FirstName= dr("fname"),
.LastName = dr("lastName")
})
'Does personList need to be converted to a different format?
Return personList
End Function
End Class
ASPXページ
jQuery("#list1").jqGrid({
url: "http://localhost/WebService1.asmx/GetPersonList",
datatype: "json",
mtype: 'POST',
colNames: ['FirstName', 'LastName'],
colModel: [
{ name: 'FirstName', index: 'FirstName', width: 90 },
{ name: 'LastName', index: 'LastName', width: 90 }
],
rowNum:10,
rowList: [10,20,30],
pager: '#pager1',
viewrecords: true,
caption: "Person List"
});