Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
280
Passing String Data from DataSourceURL
posted

We are using Infragistics 13.2 and ASP.NET and are trying to use a DataSourceURL pointing to a static WebMethod which returns a String back to the client, but we keep getting below exception when binding the datasource:

Unhandled exception at line 226, column 27387 in http://localhost:55765/igniteUI/js/infragistics.core.js
0x800a138f - JavaScript runtime error: Unable to get property 'length' of undefined or null reference

We need to return a String:

This seems to be a general exception when returning a String from a DataSourceURL web method, but we cannot change to returning a specific object. Due to our data set being generated by user input at runtime we cannot know what columns will exist or how many. The only thing we have to work with is a C# DataTable (which cannot be serialized "as is" due to circular references) so we are building our own JSON and hence we need to return a String, not an object from the server web method.

Example:

In the attached example is a simplified case to illustrate my point. When the example code is executed as is, the JavaScript error above will be thrown. If the example is modified simply to return the object DataResult instead of the serialized version of the object (in other words, the .ToJSON() call is removed and the return type of the web method is changed to DataResult) everything works again.

Can you please look at this and provide a sample where the web method returns an already serialized object, that is a String, back to the client? I assume this has to do with flagging for parsing the string to a JS object, even if it is returned as a String from the web method.

WebApplication1.zip
Parents Reply Children