Jul 15, 2011, 5:41 PM
[CLOSED] Using JsonReader and everything is empty
Hi guys,
hit somethign new to me again and not sure I understand. We have a GridPanel which we want to save the data to Oracle. So from what I understand we are using JSON reader to read the data in the Grid. I did a watch out the JSON reader and all my value are 0 or "" even though I entered data in the fields.
I will post the code relative to this problem.
My Store
"[{"OfferID":0,"SeqNr":0,"WorkCatgCd":"","NrOfHours" :0,"WorkComment":"","OfferID,SeqNr":-2}]"
I hope this is enough to help you out. I probably couldn't pull out the code to get a functional grid working since I wouldn't even know where to start ;)
Thanks so much,
Bert
hit somethign new to me again and not sure I understand. We have a GridPanel which we want to save the data to Oracle. So from what I understand we are using JSON reader to read the data in the Grid. I did a watch out the JSON reader and all my value are 0 or "" even though I entered data in the fields.
I will post the code relative to this problem.
My Store
<asp:ObjectDataSource ID="dsWorkInv" runat="server" SelectMethod="FindByID"
TypeName="UOttawa.BusinessObjects.WorkHoursCollection"
OldValuesParameterFormatString="original_{0}" >
<SelectParameters>
<asp:QueryStringParameter DefaultValue="0" Name="OfferID" QueryStringField="id" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
<ext:Store ID="stoWorkInv" runat="server" DataSourceID="dsWorkInv" OnBeforeStoreChanged="stoWorkHours_OnBeforeStoreChanged">
<Reader>
<ext:JsonReader IDProperty="OfferID,SeqNr">
<Fields>
<ext:RecordField Name="OfferID" Type="Int"/>
<ext:RecordField Name="SeqNr" Type="Int"/>
<ext:RecordField Name="WorkCatgCd" Type="String"/>
<ext:RecordField Name="NrOfHours" Type="Float"/>
<ext:RecordField Name="WorkComment" Type="String"/>
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
There's also a bit of code on the save button. <ext:Button ID="btnSave" runat="server" Text="Save" Icon="Disk" OnClientClick="#{btnSave}.disable();return true;">
<DirectEvents>
<Click OnEvent="btnSave_Click" >
<ExtraParams>
<ext:Parameter Name="WorkHours" Value="Ext.encode(#{grdWorkInv}.getRowsValues(false))" Mode="Raw" />
</ExtraParams>
</Click>
</DirectEvents>
</ext:Button>
My ClassImports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Public Class WorkHours
Private _lngOfferId As Long = 0
Private _lngSeqNr As Long = 0
Private _strWorkCatgCd As String = ""
Private _lngNrOfHours As Decimal = 0
Private _strWorkComment As String = ""
Public Sub New(ByVal OfferId As Long, ByVal SeqNr As Long, ByVal WorkCatgCd As String, ByVal NrOfHours As Decimal, ByVal WorkComment As String)
_lngOfferId = OfferId
_lngSeqNr = SeqNr
_strWorkCatgCd = WorkCatgCd
_lngNrOfHours = NrOfHours
_strWorkComment = WorkComment
End Sub
Public Sub New()
End Sub
Public Function Validate(ByVal lang As Language, ByVal action As DatabaseAction) As StatusMessage
'Perform data validation and return a proper code from the StatusMessage.vb list.
'If WorkID = 0 Then
' Return New StatusMessage(ErrorCodes.WorkInventoryNil)
If WorkCatgCd = "" Then
Return New StatusMessage(ErrorCodes.WorkCategoryCodeNil)
ElseIf NrOfHours = Nothing Then
Return New StatusMessage(ErrorCodes.NrOfHoursNil)
Else
Return New StatusMessage(ErrorCodes.None)
End If
End Function
Public Property OfferId() As Long
Get
Return _lngOfferId
End Get
Set(ByVal value As Long)
_lngOfferId = value
End Set
End Property
Public Property SeqNr() As Long
Get
Return _lngSeqNr
End Get
Set(ByVal value As Long)
_lngSeqNr = value
End Set
End Property
Public Property WorkCatgCd() As String
Get
Return _strWorkCatgCd
End Get
Set(ByVal value As String)
_strWorkCatgCd = value
End Set
End Property
Public Property NrOfHours() As Decimal
Get
Return _lngNrOfHours
End Get
Set(ByVal value As Decimal)
_lngNrOfHours = value
End Set
End Property
Public Property WorkComment() As String
Get
Return _strWorkComment
End Get
Set(ByVal value As String)
_strWorkComment = value
End Set
End Property
End Class
And the function I call to read the data and put them in my class Private Function PopulateWorkHours() As List(Of WorkHours)
'Get the course schedule table
Dim jsonData As String = Session("_StudentOfferSaveAjaxEventArgs")
'Dim xmlCourseSchedule As XmlNode = JSON.DeserializeXmlNode("{records:{record:" + jsonData + "}}")
Dim items As List(Of WorkHours) = New List(Of WorkHours)()
If jsonData Is Nothing Then
Return items
End If
Dim settings As JsonSerializerSettings = New JsonSerializerSettings()
settings.MissingMemberHandling = MissingMemberHandling.Ignore
items = JsonConvert.DeserializeObject(jsonData, GetType(List(Of WorkHours)), settings)
Return items
End Function
And this is what is see in my watch"[{"OfferID":0,"SeqNr":0,"WorkCatgCd":"","NrOfHours" :0,"WorkComment":"","OfferID,SeqNr":-2}]"
I hope this is enough to help you out. I probably couldn't pull out the code to get a functional grid working since I wouldn't even know where to start ;)
Thanks so much,
Bert
Last edited by Daniil; Jul 18, 2011 at 5:37 PM.
Reason: [CLOSED]