Hi all,
I'm having huge problems attempting to bind a radgrid to a WCF service using JSON using the built-in ClientSettings-DataBinding
The various code components:
WCF Call - returning a WSResponse_Machine_Readings class
Interface:
<
OperationContract
()> _
<
WebInvoke
(
Method:
=
"POST"
,
ResponseFormat:
=
WebMessageFormat
.Json,
RequestFormat:
=
WebMessageFormat
.Json,
BodyStyle:
=
WebMessageBodyStyle
.Wrapped,
UriTemplate:
=
"GetMachineReadings/"
)> _
Function GetMachineReadings(ByVal startRowIndex As Integer, ByVal maximumRows As Integer, ByVal sortExpression As String, ByVal filterExpression As String) As Machines.WSResponse_Machine_Readings
Function:
Public Function GetMachineReadings(ByVal startRowIndex As Integer, ByVal maximumRows As Integer, ByVal sortExpression As String, ByVal filterExpression As String) As Machines.WSResponse_Machine_Readings Implements IRicohData.GetMachineReadings
Dim orgID As Integer = 39311
Dim Serial As String = "W3009606995"
Dim Contract As String = "233807"
Dim _response As New Machines.WSResponse_Machine_Readings
Dim _items As New List(Of Machines.MachineReading)
_items = Machines.getReadingsList(orgID, "", Serial, Contract)
_response.Count = _items.Count
_response.Data = _items
Return _response
End Function
WSResponse_Machine_Readings Class:
Public Class WSResponse_Machine_Readings
Public Property Count()
Public Property Data() As List(Of MachineReading)
End Class
MachineReading Class:
Public Class MachineReading
Public Property ReadingDate
Public Property ReadingType
Public Property ReadingBLK
Public Property ReadingCLR
End Class
Function populating my List(of MachineReading):
Public Shared Function getReadingsList(ByVal orgID As Integer, ByVal Model As String, ByVal Serial As String, ByVal Contract As String) As List(Of MachineReading)
Dim results As DataView = executeGetContractData(orgID, Model, Serial, Contract, "Readings")
Dim _items As New List(Of MachineReading)
For Each result As DataRowView In results
Dim _item As New MachineReading
With _item
.ReadingDate = result("ReadingDate").trim()
.ReadingType = result("ReadingType").trim()
.ReadingBLK = result("ReadingBLK").trim()
.ReadingCLR = result("ReadingCLR").trim()
End With
_items.Add(_item)
Next
Return _items
End Function
RadGrid definition:
<
telerik:RadGrid
ID
=
"gridReadings"
runat
=
"server"
AutoGenerateColumns
=
"False"
AllowPaging
=
"True"
Height
=
"420px"
Width
=
"850px"
EnableViewState
=
"False"
BorderStyle
=
"None"
AllowSorting
=
"True"
PageSize
=
"10"
ClientSettings-Scrolling-UseStaticHeaders
=
"true"
CellSpacing
=
"0"
GridLines
=
"None"
>
<
MasterTableView
Font-Size
=
"90%"
NoMasterRecordsText
=
"No readings to display"
>
<
CommandItemSettings
ExportToPdfText
=
"Export to PDF"
></
CommandItemSettings
>
<
RowIndicatorColumn
Visible
=
"True"
FilterControlAltText
=
"Filter RowIndicator column"
>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
Visible
=
"True"
FilterControlAltText
=
"Filter ExpandColumn column"
>
</
ExpandCollapseColumn
>
<
Columns
>
<
telerik:GridBoundColumn
FilterControlAltText
=
"Filter column column"
HeaderText
=
"Date"
HeaderStyle-Width
=
"100"
DataField
=
"ReadingDate"
UniqueName
=
"ReadingDate"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
FilterControlAltText
=
"Filter column1 column"
HeaderText
=
"Type"
HeaderStyle-Width
=
"200"
DataField
=
"ReadingType"
UniqueName
=
"ReadingType"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
FilterControlAltText
=
"Filter column2 column"
HeaderText
=
"Black"
HeaderStyle-Width
=
"100"
DataField
=
"ReadingBLK"
UniqueName
=
"ReadingBLK"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
FilterControlAltText
=
"Filter column4 column"
HeaderText
=
"Colour"
HeaderStyle-Width
=
"100"
DataField
=
"ReadingCLR"
UniqueName
=
"ReadingCLR"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
EditFormSettings
>
<
EditColumn
FilterControlAltText
=
"Filter EditCommandColumn column"
>
</
EditColumn
>
</
EditFormSettings
>
<
PagerStyle
AlwaysVisible
=
"True"
PageButtonCount
=
"5"
></
PagerStyle
>
</
MasterTableView
>
<
ClientSettings
>
<
ClientEvents
/>
<
Scrolling
AllowScroll
=
"True"
UseStaticHeaders
=
"True"
SaveScrollPosition
=
"true"
/>
<
DataBinding
SelectMethod
=
"GetMachineReadings/"
Location
=
"https://ws.ricoh.co.nz/Services/Ricoh/RicohData.svc"
FilterParameterType
=
"List"
SortParameterType
=
"List"
>
</
DataBinding
>
</
ClientSettings
>
<
PagerStyle
AlwaysVisible
=
"true"
/>
<
GroupingSettings
CaseSensitive
=
"False"
/>
<
FilterMenu
EnableImageSprites
=
"False"
>
</
FilterMenu
>
</
telerik:RadGrid
>
JSON return from the service:
{"GetMachineReadingsResult":{"Count":31,"Data":[{"ReadingBLK":"22,554","ReadingCLR":"0","ReadingDate":"14\/09\/13","ReadingType":"Customer Reading"},{"ReadingBLK":"21,206","ReadingCLR":"0","ReadingDate":"14\/08\/13","ReadingType":"Customer Reading"},{"ReadingBLK":"20,787","ReadingCLR":"0","ReadingDate":"07\/08\/13","ReadingType":"Engineer Reading"},{"ReadingBLK":"19,872","ReadingCLR":"0","ReadingDate":"14\/07\/13","ReadingType":"Customer Reading"},{"ReadingBLK":"18,826","ReadingCLR":"0","ReadingDate":"14\/06\/13","ReadingType":"Customer Reading"},{"ReadingBLK":"17,044","ReadingCLR":"0","ReadingDate":"14\/05\/13","ReadingType":"Customer Reading"},{"ReadingBLK":"16,155","ReadingCLR":"0","ReadingDate":"14\/04\/13","ReadingType":"Customer Reading"},{"ReadingBLK":"15,049","ReadingCLR":"0","ReadingDate":"14\/03\/13","ReadingType":"Customer Reading"},{"ReadingBLK":"13,470","ReadingCLR":"0","ReadingDate":"14\/02\/13","ReadingType":"Customer Reading"},{"ReadingBLK":"13,470","ReadingCLR":"0","ReadingDate":"14\/01\/13","ReadingType":"Customer Reading"},{"ReadingBLK":"13,405","ReadingCLR":"0","ReadingDate":"14\/12\/12","ReadingType":"Customer Reading"},{"ReadingBLK":"12,783","ReadingCLR":"0","ReadingDate":"14\/11\/12","ReadingType":"Customer Reading"},{"ReadingBLK":"12,113","ReadingCLR":"0","ReadingDate":"14\/10\/12","ReadingType":"Customer Reading"},{"ReadingBLK":"11,424","ReadingCLR":"0","ReadingDate":"14\/09\/12","ReadingType":"Customer Reading"},{"ReadingBLK":"10,228","ReadingCLR":"0","ReadingDate":"14\/08\/12","ReadingType":"Customer Reading"},{"ReadingBLK":"9,310","ReadingCLR":"0","ReadingDate":"14\/07\/12","ReadingType":"Customer Reading"},{"ReadingBLK":"8,997","ReadingCLR":"0","ReadingDate":"14\/06\/12","ReadingType":"Customer Reading"},{"ReadingBLK":"8,320","ReadingCLR":"0","ReadingDate":"14\/05\/12","ReadingType":"Customer Reading"},{"ReadingBLK":"6,809","ReadingCLR":"0","ReadingDate":"14\/04\/12","ReadingType":"Customer Reading"},{"ReadingBLK":"6,809","ReadingCLR":"0","ReadingDate":"14\/03\/12","ReadingType":"Customer Reading"},{"ReadingBLK":"6,329","ReadingCLR":"0","ReadingDate":"14\/02\/12","ReadingType":"Customer Reading"},{"ReadingBLK":"5,841","ReadingCLR":"0","ReadingDate":"14\/01\/12","ReadingType":"Customer Reading"},{"ReadingBLK":"5,819","ReadingCLR":"0","ReadingDate":"14\/12\/11","ReadingType":"Customer Reading"},{"ReadingBLK":"5,306","ReadingCLR":"0","ReadingDate":"14\/11\/11","ReadingType":"Customer Reading"},{"ReadingBLK":"4,576","ReadingCLR":"0","ReadingDate":"14\/10\/11","ReadingType":"Customer Reading"},{"ReadingBLK":"4,224","ReadingCLR":"0","ReadingDate":"14\/09\/11","ReadingType":"Customer Reading"},{"ReadingBLK":"3,071","ReadingCLR":"0","ReadingDate":"14\/08\/11","ReadingType":"Customer Reading"},{"ReadingBLK":"1,988","ReadingCLR":"0","ReadingDate":"14\/07\/11","ReadingType":"Customer Reading"},{"ReadingBLK":"1,988","ReadingCLR":"0","ReadingDate":"14\/06\/11","ReadingType":"Customer Reading"},{"ReadingBLK":"119","ReadingCLR":"0","ReadingDate":"14\/05\/11","ReadingType":"Customer Reading"},{"ReadingBLK":"119","ReadingCLR":"0","ReadingDate":"02\/05\/11","ReadingType":"Initial Reading"}]}}
I know the service is returning results, and I can output data using jquery, but the grid simple refuses to bind.
I've searched the forums and examples and can't find anything that will help me resolve this problem.
Any help would be appreciated
Cheers!