剣道グリッドでデータを表示するのに問題があります。私のシナリオは次のとおりです。特定のプロジェクトのタスクに関する情報を表示するグリッドがあります。そのプロジェクトに関連するタスクのみがグリッドに表示されます。サーバーからデータを取得するために ajax バインディングを使用しています。ただし、グリッドにはデータが表示されていません。Read 関数が正しい結果を返していることはかなり確信しており、正しい形式で考えていますが、明らかに間違っています。以下は私のコードです。
ここに私のモデル定義があります:
Public Class TaskViewModel
Public Property IdTasks As Integer
Public Property Task As String
Public Property AssignedToId As Nullable(Of Integer)
Public Property StartDate As Nullable(Of Date)
Public Property DueDate As Nullable(Of Date)
Public Property usersAssignedTo As UserViewModel
Public Property costChange As CostChangeViewModel
End Class
Public Class CostChangeViewModel
Public Property Text as String
Public Property Value as Integer
End Class
Public Class UserViewModel
Public Property Text as String
Public Property Value as Integer
End Class
コントローラーからアクションを読み取る
Function Tasks_Read(familyId As Integer) As JsonResult
'get the customer family that is being viewed on the margin report
Dim custFamily As CustomerFamilies = (From a In dbLMT.CustomerFamilies Where a.CustomerFamilyId = familyId).Single
'get a list of tasks related to that customer family
Dim lstTasks As IQueryable(Of Tasks) = getTaskList(custFamily)
'create a queryable of the task view model and select only those properties
Dim lstTaskViewModel As IQueryable(Of TaskViewModel) = (From a In lstTasks Select New TaskViewModel With {.IdTasks = a.IdTasks, .Task = a.Task, .AssignedToId = a.AssignedToId, .usersAssignedTo = New UserViewModel With {.Text = a.usersAssignedTo.FirstName & " " & a.usersAssignedTo.LastName, .Value = a.usersAssignedTo.IdUsers}, .StartDate = a.StartDate, .DueDate = a.DueDate, .costChange = New CostChangeViewModel With {.Text = a.costChange.CostChangeDesc, .Value = a.costChange.CostChangeProjectId}})
Return Json(lstTaskViewModel, JsonRequestBehavior.AllowGet)
End Function
上記の関数は正常に動作しているように見え、lstTaskViewModel には正しいプロパティを持つ正しいタスクが含まれています。
私のグリッドコードを以下に示します。
@Html.Kendo.Grid(Of TaskViewModel).Name("gridTasks").Columns(Sub(col)
col.Bound(Function(p) p.IdTasks).Title("Id")
col.Bound(Function(p) p.costChange).Title("Cost Change Project").ClientTemplate("#=costChange.Text#").Width(200)
col.Bound(Function(p) p.Task).Title("Task").Width(400)
col.Bound(Function(p) p.StartDate).Title("Start Date").Width(100).Format("{0:MM/dd/yyyy}")
col.Bound(Function(p) p.DueDate).Title("Due Date").Width(100).Format("{0:MM/dd/yyyy}")
col.Bound(Function(p) p.usersAssignedTo).Title("Assigned To").ClientTemplate("#=usersAssignedTo.Text#").Width(100)
End Sub).DataSource(Sub(ds)
ds.Ajax().Read(Sub(rd)
rd.Action("Tasks_Read", "Reports").Data("getFamilyId")
End Sub).Model(Sub(model)
model.Id(Function(p) p.IdTasks)
End Sub)
End Sub).AutoBind(True)
上記のグリッドを使用して、新しいタスクを正常に作成して表示しましたが、Tasks_Readから渡されたタスクのリストが表示されません。(テスト目的でデータを読み取っていないものはすべて取り出しました)
IE デバッガーを使用して、Tasks_Readがグリッドに返すJSON 文字列を取得しました。
[{"IdTasks":7027,"Task":"this is a test to ensure that creating a task and an issue is possible","AssignedToId":3151,"StartDate":"\/Date(1438056000000)\/","DueDate":"\/Date(1438228800000)\/","usersAssignedTo":{"Text":"Eric Hemphill","Value":3151},"costChange":{"Text":"Change Final Assy AT from 0.82 to 0.73","Value":125}}]
私には、JSON の結果がグリッドのモデルに適合しているように見えますが、グリッドにはデータが表示されません。同様の問題があるすべての投稿を読んだと思いますが、これまでのところ何も機能していません。
どんなアイデアでも大歓迎です。助けてくれてありがとう!