I am having issues binding an XML dataset to a Kendo Grid using the Kendo DataSource object. My grid renders but has no rows.
Here is the page on which I am drawing the Grid and creating the DataSource (Default.aspx):
And here is the XAML dataset being returned by my web service (data_reader_webservice.asmx/GetHistoryLogXml ):
And here is a copy of the web service code itself (data_reader_webservice.asmx.cs):
If anyone can provide any insights as to what is wrong I would greatly appreciate it.
Thanks again,
Ian
Here is the page on which I am drawing the Grid and creating the DataSource (Default.aspx):
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ians_samples.Default" %>
<!DOCTYPE html>
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
<
script
src
=
"js/kendo/jquery.min.js"
type
=
"text/javascript"
></
script
>
<
script
src
=
"js/kendo/kendo.all.min.js"
type
=
"text/javascript"
></
script
>
<
link
href
=
"css/default.css"
rel
=
"Stylesheet"
/>
<
link
href
=
"css/kendo/kendo.common.min.css"
rel
=
Stylesheet
/>
<
link
href
=
"css/kendo/kendo.default.min.css"
rel
=
Stylesheet
/>
<
style
>
</
style
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
>
<
Services
>
<
asp:ServiceReference
Path
=
"~/data_reader_webservice.asmx"
/>
</
Services
>
</
asp:ScriptManager
>
<
div
>
<
div
class
=
"k-content"
>
<
div
id
=
"splitter_test"
style
=
"height: 300px;"
>
<
div
>
<
p
> Top </
p
>
</
div
>
<
div
>
<
div
id
=
"grid_test"
>
</
div
>
</
div
>
<
div
>
<
p
> Bottom </
p
>
</
div
>
</
div
>
</
div
>
<
script
>
$(document).ready(function () {
$("#splitter_test").kendoSplitter({
orientation: "vertical",
panes: [
{ collapsible: false, resizable: true, size: "50px" },
{ collapsible: false, resizable: true },
{ resizable: true, size: "50px" }
]
});
var dataSource = new kendo.data.DataSource({
transport: {
read: {
type: "POST",
url: "data_reader_webservice.asmx/GetHistoryLogXml"
}
},
schema: {
type: "xml",
data: "/tblHistoryLog/tblHistoryLog",
model: {
fields: {
LogID: "LogID/text()",
LogDate: "LogDate/text()",
Modules: "Modules/text()",
Message: "Message/text()"
}
}
}
});
$("#grid_test").kendoGrid({
dataSource: dataSource,
columns: [
{ field: "LogID", title: "Log ID" },
{ field: "LogDate", title: "Log Date" },
{ field: "Modules", title: "Module" },
{ field: "Message", title: "Message" }
]
});
});
</
script
>
</
div
>
</
form
>
</
body
>
</
html
>
And here is the XAML dataset being returned by my web service (data_reader_webservice.asmx/GetHistoryLogXml ):
<
tblHistoryLog
>
<
tblHistoryLog
>
<
LogID
>2211410</
LogID
>
<
LogDate
>2012-02-08T10:20:48.933-05:00</
LogDate
>
<
Modules
>TAL</
Modules
>
<
Message
>The AeroScout tagging system has reported movement of tag 000CCC77332E to local position (21536,16149,0) within map Coleman Mine 4700 Level.</
Message
>
<
MessageType
>0</
MessageType
>
<
UltimateTriggerID
>2211410</
UltimateTriggerID
>
<
IsMultiTrigger
>false</
IsMultiTrigger
>
</
tblHistoryLog
>
<
tblHistoryLog
>
<
LogID
>2211411</
LogID
>
<
LogDate
>2012-02-08T10:20:48.933-05:00</
LogDate
>
<
Modules
>TAL</
Modules
>
<
Message
>Entity 239 has entered Zone 21. Its current position is (9290.36412811279,-23460,-7493.75833129883).</
Message
>
<
MessageType
>1</
MessageType
>
<
ProximateTriggerID
>2211410</
ProximateTriggerID
>
<
UltimateTriggerID
>2211410</
UltimateTriggerID
>
<
IsMultiTrigger
>false</
IsMultiTrigger
>
</
tblHistoryLog
>
<
tblHistoryLog
>
<
LogID
>2211408</
LogID
>
<
LogDate
>2012-02-08T10:20:04.58-05:00</
LogDate
>
<
Modules
>TAL</
Modules
>
<
Message
>The AeroScout tagging system has reported movement of tag 000CCC77332E to local position (21536,16149,0) within map Coleman Mine 4700 Level.</
Message
>
<
MessageType
>0</
MessageType
>
<
UltimateTriggerID
>2211408</
UltimateTriggerID
>
<
IsMultiTrigger
>false</
IsMultiTrigger
>
</
tblHistoryLog
>
<
tblHistoryLog
>
<
LogID
>2211409</
LogID
>
<
LogDate
>2012-02-08T10:20:04.58-05:00</
LogDate
>
<
Modules
>TAL</
Modules
>
<
Message
>Entity 239 has entered Zone 21. Its current position is (9290.36412811279,-23460,-7493.75833129883).</
Message
>
<
MessageType
>1</
MessageType
>
<
ProximateTriggerID
>2211408</
ProximateTriggerID
>
<
UltimateTriggerID
>2211408</
UltimateTriggerID
>
<
IsMultiTrigger
>false</
IsMultiTrigger
>
</
tblHistoryLog
>
<
tblHistoryLog
>
<
LogID
>2211406</
LogID
>
<
LogDate
>2012-02-08T10:19:18.387-05:00</
LogDate
>
<
Modules
>TAL</
Modules
>
<
Message
>The AeroScout tagging system has reported movement of tag 000CCC77332E to local position (21536,16149,0) within map Coleman Mine 4700 Level.</
Message
>
<
MessageType
>0</
MessageType
>
<
UltimateTriggerID
>2211406</
UltimateTriggerID
>
<
IsMultiTrigger
>false</
IsMultiTrigger
>
</
tblHistoryLog
>
<
tblHistoryLog
>
<
LogID
>2211407</
LogID
>
<
LogDate
>2012-02-08T10:19:18.387-05:00</
LogDate
>
<
Modules
>TAL</
Modules
>
<
Message
>Entity 239 has entered Zone 21. Its current position is (9290.36412811279,-23460,-7493.75833129883).</
Message
>
<
MessageType
>1</
MessageType
>
<
ProximateTriggerID
>2211406</
ProximateTriggerID
>
<
UltimateTriggerID
>2211406</
UltimateTriggerID
>
<
IsMultiTrigger
>false</
IsMultiTrigger
>
</
tblHistoryLog
>
<
tblHistoryLog
>
<
LogID
>2211404</
LogID
>
<
LogDate
>2012-02-08T10:17:48.15-05:00</
LogDate
>
<
Modules
>TAL</
Modules
>
<
Message
>The AeroScout tagging system has reported movement of tag 000CCC77332E to local position (21536,16149,0) within map Coleman Mine 4700 Level.</
Message
>
<
MessageType
>0</
MessageType
>
<
UltimateTriggerID
>2211404</
UltimateTriggerID
>
<
IsMultiTrigger
>false</
IsMultiTrigger
>
</
tblHistoryLog
>
<
tblHistoryLog
>
<
LogID
>2211405</
LogID
>
<
LogDate
>2012-02-08T10:17:48.15-05:00</
LogDate
>
<
Modules
>TAL</
Modules
>
<
Message
>Entity 239 has entered Zone 21. Its current position is (9290.36412811279,-23460,-7493.75833129883).</
Message
>
<
MessageType
>1</
MessageType
>
<
ProximateTriggerID
>2211404</
ProximateTriggerID
>
<
UltimateTriggerID
>2211404</
UltimateTriggerID
>
<
IsMultiTrigger
>false</
IsMultiTrigger
>
</
tblHistoryLog
>
<
tblHistoryLog
>
<
LogID
>2211403</
LogID
>
<
LogDate
>2012-02-08T10:16:17.743-05:00</
LogDate
>
<
Modules
>TAL</
Modules
>
<
Message
>Entity 239 has entered Zone 21. Its current position is (9290.36412811279,-23460,-7493.75833129883).</
Message
>
<
MessageType
>1</
MessageType
>
<
ProximateTriggerID
>2211402</
ProximateTriggerID
>
<
UltimateTriggerID
>2211402</
UltimateTriggerID
>
<
IsMultiTrigger
>false</
IsMultiTrigger
>
</
tblHistoryLog
>
<
tblHistoryLog
>
<
LogID
>2211402</
LogID
>
<
LogDate
>2012-02-08T10:16:17.73-05:00</
LogDate
>
<
Modules
>TAL</
Modules
>
<
Message
>The AeroScout tagging system has reported movement of tag 000CCC77332E to local position (21536,16149,0) within map Coleman Mine 4700 Level.</
Message
>
<
MessageType
>0</
MessageType
>
<
UltimateTriggerID
>2211402</
UltimateTriggerID
>
<
IsMultiTrigger
>false</
IsMultiTrigger
>
</
tblHistoryLog
>
<
tblHistoryLog
>
<
LogID
>2211400</
LogID
>
<
LogDate
>2012-02-08T10:15:31.61-05:00</
LogDate
>
<
Modules
>TAL</
Modules
>
<
Message
>The AeroScout tagging system has reported movement of tag 000CCC77332E to local position (21536,16149,0) within map Coleman Mine 4700 Level.</
Message
>
<
MessageType
>0</
MessageType
>
<
UltimateTriggerID
>2211400</
UltimateTriggerID
>
<
IsMultiTrigger
>false</
IsMultiTrigger
>
</
tblHistoryLog
>
<
tblHistoryLog
>
<
LogID
>2211401</
LogID
>
<
LogDate
>2012-02-08T10:15:31.61-05:00</
LogDate
>
<
Modules
>TAL</
Modules
>
<
Message
>Entity 239 has entered Zone 21. Its current position is (9290.36412811279,-23460,-7493.75833129883).</
Message
>
<
MessageType
>1</
MessageType
>
<
ProximateTriggerID
>2211400</
ProximateTriggerID
>
<
UltimateTriggerID
>2211400</
UltimateTriggerID
>
<
IsMultiTrigger
>false</
IsMultiTrigger
>
</
tblHistoryLog
>
<
tblHistoryLog
>
<
LogID
>2211399</
LogID
>
<
LogDate
>2012-02-08T10:14:01.313-05:00</
LogDate
>
<
Modules
>TAL</
Modules
>
<
Message
>Entity 239 has entered Zone 21. Its current position is (9290.36412811279,-23460,-7493.75833129883).</
Message
>
<
MessageType
>1</
MessageType
>
<
ProximateTriggerID
>2211398</
ProximateTriggerID
>
<
UltimateTriggerID
>2211398</
UltimateTriggerID
>
<
IsMultiTrigger
>false</
IsMultiTrigger
>
</
tblHistoryLog
>
<
tblHistoryLog
>
And here is a copy of the web service code itself (data_reader_webservice.asmx.cs):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
using System.Web.Script.Services;
using System.Web.Script.Serialization;
using System.Text;
namespace ians_samples
{
/// <
summary
>
/// Summary description for data_reader_webservice
/// </
summary
>
[WebService(Namespace = "ians_samples")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class data_reader_webservice : System.Web.Services.WebService
{
[WebMethod]
public DataSet GetHistoryLogDataSet()
{
DataSet returnSet = new DataSet();
string sConn = ConfigurationManager.ConnectionStrings["NRG-ECO_DB"].ToString();
string sSQL = "SELECT * FROM tblHistoryLog WHERE LogDate BETWEEN '" + DateTime.Now.AddDays(-100).ToString() + "' AND '" + DateTime.Now.ToString() + "' ORDER BY LogDate DESC";
SqlDataAdapter da = new SqlDataAdapter(sSQL, new SqlConnection(sConn));
da.Fill(returnSet, "tblHistoryLog");
returnSet.DataSetName = "tblHistoryLog";
return returnSet;
}
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Xml)]
public string GetHistoryLogXml()
{
DataSet returnSet = new DataSet();
string sConn = ConfigurationManager.ConnectionStrings["NRG-ECO_DB"].ToString();
string sSQL = "SELECT * FROM tblHistoryLog WHERE LogDate BETWEEN '" + DateTime.Now.AddDays(-100).ToString() + "' AND '" + DateTime.Now.ToString() + "' ORDER BY LogDate DESC";
SqlDataAdapter da = new SqlDataAdapter(sSQL, new SqlConnection(sConn));
da.Fill(returnSet, "tblHistoryLog");
returnSet.DataSetName = "tblHistoryLog";
return returnSet.GetXml();
}
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string GetHistoryLogJSON()
{
DataTable returnSet = new DataTable();
string sConn = ConfigurationManager.ConnectionStrings["NRG-ECO_DB"].ToString();
string sSQL = "SELECT * FROM tblHistoryLog WHERE LogDate BETWEEN '" + DateTime.Now.AddDays(-100).ToString() + "' AND '" + DateTime.Now.ToString() + "' ORDER BY LogDate DESC";
SqlDataAdapter da = new SqlDataAdapter(sSQL, new SqlConnection(sConn));
da.Fill(returnSet);
return GetJSONString(returnSet);
}
// borrowed from http://weblogs.asp.net/navaidakhtar/archive/2008/07/08/converting-data-table-dataset-into-json-string.aspx
public static string GetJSONString(DataTable Dt)
{
string[] StrDc = new string[Dt.Columns.Count];
string HeadStr = string.Empty;
for (int i = 0; i < Dt.Columns.Count; i++)
{
StrDc[i] = Dt.Columns[i].Caption;
HeadStr += "\"" + StrDc[i] + "\" : \"" + StrDc[i] + i.ToString() + "¾" + "\",";
}
HeadStr = HeadStr.Substring(0, HeadStr.Length - 1);
StringBuilder Sb = new StringBuilder();
Sb.Append("{\"" + Dt.TableName + "\" : [");
for (int i = 0; i < Dt.Rows.Count; i++)
{
string TempStr = HeadStr;
Sb.Append("{");
for (int j = 0; j < Dt.Columns.Count; j++)
{
TempStr = TempStr.Replace(Dt.Columns[j] + j.ToString() + "¾", Dt.Rows[i][j].ToString());
}
Sb.Append(TempStr + "},");
}
Sb = new StringBuilder(Sb.ToString().Substring(0, Sb.ToString().Length - 1));
Sb.Append("]}");
return Sb.ToString();
}
}
}
If anyone can provide any insights as to what is wrong I would greatly appreciate it.
Thanks again,
Ian