I am able to bind XML data that is built locally (e.g. http://www.igniteui.com/data-source/xml-binding) to a datasource and then bind that datasource to a grid. But when I change the ig.datasource's dataSource to a Web API URL returning the same exact XML string, I consistently get an error such as this:
Error: There was an error parsing the XML data and applying the defined data schema: data.evaluate is not a functionhttp://localhost:53008/igniteui/js/modules/infragistics.datasource.jsLine 37
I've also seen the same error with an inner message suggesting the problem is instead related to root.IterateNext, but attempting to apply this fix (http://es.infragistics.com/community/forums/p/69866/353775.aspx) does not work.
Initially, I had thought that the issue was the Web API's XMLFormatter alone, but if I observe the XML in Firebug, it is identical to the XML that I had used successfully when constructed locally. In other words, I don't see any obvious issue in the construction of the XML.
I have attempted to eliminate as many factors as possible, such as:
#1) It doesn't matter whether I bind to the grid or not. It's strictly an issue with the datasource.#2) It doesn't matter whether I pass across an xmlstring or xmldocument.#3) It doesn't matter if I remove the JSONFormatter entirely from the Web API configuration.#4) It doesn't matter if I use datasource or xmldatasource.
I'm at a loss for what's wrong here. The Infragistics samples are seriously lacking real-life remote data retrieval scenarios, so I haven't found anything to help.
Jason
Can you provide us with a sample of the data and code that you are working with? It'll help me provide you with an example better suited for your needs.
I poached most of the code from here, http://www.igniteui.com/data-source/xml-binding, with slight modifications.
/exemel/index.html
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head> <title></title> <script src="../scripts/modernizr-2.6.2.js"></script> <script src="../scripts/jquery-1.10.2.min.js"></script> <script src="../scripts/jquery-ui.min.js"></script> <script src="../igniteui/js/infragistics.loader.js"></script></head><body> <table id="table" class="standard-grid"> <thead> <tr> <th> Email </th> <th> Age </th> <th> Name </th> </tr> </thead> <tbody></tbody> </table> <br /> <script> $.ig.loader({ scriptPath: '../igniteui/js/', cssPath: '../igniteui/css/', ////string representing which component resources are required resources: "igDataSource" }); $(function () { //alert('k'); // Renders the table var renderTable = function (success, error) { var template = "<tr><td>{Email}</td><td>{Age}</td><td>{Name}</td></tr>"; if (success) { $("#table tbody").empty(); $($.ig.tmpl(template, ds.dataView())).appendTo("#table tbody"); } else { alert(error); } } // The $.ig.DataSchema is used to define the schema of the data var xmlSchema = new $.ig.DataSchema("xml", { //searchField serves as the base node(s) for the XPaths searchField: "//Person", fields: [ { name: "Name", xpath: "./@Name" }, { name: "Email", xpath: "Details/@Email" }, { name: "Age", xpath: "Details/@Age" } ] }); // service Url var url = "/api/exemel/5"; // This code creates an $.ig.DataSource bound to oData service var ds = new $.ig.DataSource({ type: "remoteUrl", callback: renderTable, dataSource: url, schema: xmlSchema, responseDataType: "xml", responseContentType: "application/xml; charset=utf-8" }); // Binds to the underlying data ds.dataBind(); }); </script></body></html>
exemelcontroller.vb
' GET api/exemel/5 Public Function GetExemel(ByVal id As Integer) As XmlDocument ' String 'Return "value" Dim a As String = "" a = "<People>" + _ "<Person Name=""Gustava Achong"">" + _ "<Details Age=""42"" Email=""gachong@adventureworks.com"" />" + _ "</Person>" + _ "<Person Name=""Catherine Abel"">" + _ "<Details Age=""27"" Email=""cabel@adventureworks.com"" />" + _ "</Person>" + _ "<Person Name=""Kim Abercrombie"">" + _ "<Details Age=""33"" Email=""kabercrombie@adventureworks.com"" />" + _ "</Person>" + _ "</People>" Dim b As New XmlDocument b.LoadXml(a) Return b 'a End Function
Here's the Firebug Console after running: