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:
Hello Jason,
While we're investigating your issue I want to ask you a the following question:
Is there any particular reason that you're using XML in favor of JSON? There are tons of reason why JSON is the preferred format for the web.
Best regards,Martin PavlovInfragistics, Inc.
Doing our due diligence.
We have built almost exclusively large-scale, data-intensive three-tier applications over the years and have grown comfortable with ADO and, to a lesser extent, XML. We've seen the pros and cons of using JSON versus XML, and while we understand why JSON is the "preferred format" for many developers, we wanted to evaluate performance of the Ignite controls (the grid and datasource, in particular) under various conditions, including data format. I had hoped that Infragistics would have published a white paper regarding performance concerns, but I haven't seen any, so we're sorting it out ourselves.
If you're telling me that the combination of Ignite and XML is a nonstarter, that's fine; your rather limited documentation suggests that you support it, but perhaps not really.
Hi Jason,
I am currently investigating the format of the response to determine how the data should be received and how it may be getting parsed. I am testing with the code you provided and I am receiving a different error than yours. It would help if you could please let us know what the response data looks like when the request to the WebAPI returns. You can view this from the Net tab in Firebug.
Could you please also let me know what version of IgniteUI you are experiencing these errors with? You should be able to find this at the top of our script files.
I will have another update on my findings for you tomorrow after looking into this further.
Please let me know if you need further assistance with this issue.
Please see my attached sample that demonstrates one way to use the same xml data from your provided code.
I make an Ajax callback and wait for the response until I create the igDataSource using the xml data. I had to workaround with this since I was receiving errors about not being able to serialize an XmlDocument from my WebAPI Get.
The xml data is passed into the igDataSource and it is then parsed out into the html table through our template.
If you still need assistance with this issue, as I mentioned in my update yesterday, if you can please provide more information regarding the response data you are receiving, I will be able to look into the original error you were receiving.
If you have any other questions or concerns with this, please let me know.