jQWidgets Forums

Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts

  • PallaDiPelo
    Participant

    Yeah thank you
    I noticed it
    I correct both places to xml,but still doesn’t work.
    Any suggestions?

    I also try with json with this code

    	$(document).ready(function () {
        		var source = {
        			type: "GET",
        			datatype: "json",
        			datafields: [
    											{ name: 'Nome' },
    											{ name: 'Posizione' }
        			],
        			url: '../ServiziOlbm.svc/PopolaGriglia',
        			cache: false,
        			root: 'data'
        		};
    
        		//Preparing the data for use
        		var dataAdapter = new $.jqx.dataAdapter(source, {
        			contentType: 'application/json; charset=utf-8',
        			downloadComplete: function (data, textStatus, jqXHR) {
        				return data.d;
        			}
        		}
    						);
    
        		$("#jqxgrid").jqxGrid({
        			source: dataAdapter,
        			columns: [
    											{ text: 'First Name', dataField: 'Nome', width: 100 },
    											{ text: 'Last Name', dataField: 'Posizione', width: 100 }
        			]
        		});
        	});
    

    and

    	Public Function PopolaGriglia() As String
    
    		Dim OLBM_ConnDb As New OLBM_ServiziDb
    		Dim Connessione As MySqlConnection = OLBM_ConnDb.OLBM_ApriConnessioneDb
    		Dim Cmd As New MySqlCommand("SELECT nome, posizione FROM Players")
    		Dim Xjson As String
    
    		Using Connessione
    			Cmd.Parameters.AddWithValue("@Param", "value")
    			Cmd.Connection = Connessione
    			Using reader As MySqlDataReader = Cmd.ExecuteReader()
    				Xjson = Me.ReadToJson(reader)
    			End Using
    		End Using
    
    		Dim someObject As Object = Nothing
    		Dim json = New System.Web.Script.Serialization.JavaScriptSerializer()
    		Dim result = json.Deserialize(Of String)(Xjson)
    
    		'Dim Data = "{" & Chr(34) & "data:" & Chr(34) & "'[{ " & Chr(34) & "Nome" & Chr(34) & ": " & Chr(34) & "Alfreds Futterkiste" & Chr(34) & ", " & Chr(34) & "Posizione" & Chr(34) & ": " & Chr(34) & "Maria Anders" & Chr(34) & "}, {" & Chr(34) & "Nome" & Chr(34) & ": " & Chr(34) & "Sales Representative" & Chr(34) & ", " & Chr(34) & "Posizione" & Chr(34) & " : " & Chr(34) & "La mia" & Chr(34) & "}]}"
    		'Dim Data As String = "{" & Chr(34) & "data" & Chr(34) & ":[{" & Chr(34) & "firstname" & Chr(34) & ":" & Chr(34) & "Andrew" & Chr(34) & "," & Chr(34) & "lastname" & Chr(34) & ":" & Chr(34) & "Fuller" & Chr(34) & "}]}"
    		'Dim j As String = New JavaScriptSerializer().Deserialize(Of String)(json)
    		Return result
    	End Function
    
    	Public Function ReadToJson(reader As MySqlDataReader) As String
    		Dim cols As New List(Of String)(10)
    		Dim ncols As Integer = reader.FieldCount
    		For i As Integer = 0 To ncols - 1
    			cols.Add(reader.GetName(i))
    		Next
    		Dim sbJson As New StringBuilder("{" & Chr(34) & "data" & Chr(34) & ":[")
    		'process each row
    		While reader.Read()
    			sbJson.Append("{")
    			For Each col As String In cols
    				sbJson.AppendFormat("""{0}"":""{1}"", ", col, reader(col))
    			Next
    			sbJson.Replace(", ", "},", sbJson.Length - 2, 2)
    		End While
    		sbJson.Replace("},", "}]", sbJson.Length - 2, 2)
    		sbJson.Append("}")
    		Return sbJson.ToString()
    	End Function
    

    but i have issue on serializing string.
    Any help will be appreciated.

    Bye

Viewing 1 post (of 1 total)