
Christopher Martin
Top achievements
Rank 1
Christopher Martin
asked on 01 Oct 2009, 04:25 PM
Hi, I'm using client side binding with some web services registered in a RadScript manager.
All the web services return an XmlNode, and have their ResponseType set to Xml.
I can get the data fine, the problem is when I call set_dataSource and then dataBind, now rows appear in the tables.
I have autoGenerateColumns set to true in the grid.
What is the preferred method of binding a grid directly to the xml returned by the web service?
All the web services return an XmlNode, and have their ResponseType set to Xml.
I can get the data fine, the problem is when I call set_dataSource and then dataBind, now rows appear in the tables.
I have autoGenerateColumns set to true in the grid.
What is the preferred method of binding a grid directly to the xml returned by the web service?
7 Answers, 1 is accepted
0

Christopher Martin
Top achievements
Rank 1
answered on 01 Oct 2009, 06:22 PM
Well, it seems that I've (somewhat) solved my own problem.
After reading this thread I added the empty anonymous function to the OnCommand client event, and the client side script started working. I also discovered that AutoGenerateColumns isn't supported for client side binding. Not too big a deal, since I was only using it for testing.
After reading this thread I added the empty anonymous function to the OnCommand client event, and the client side script started working. I also discovered that AutoGenerateColumns isn't supported for client side binding. Not too big a deal, since I was only using it for testing.
0

Christopher Martin
Top achievements
Rank 1
answered on 01 Oct 2009, 08:37 PM
After further playing with the client side binding, I'm still having some issues.
The script calls the web method just fine, and I can retrieve the results from the server. I can call set_dataSet(result.firstChild.children) , but all I get is a bunch of empty rows. It does apprear that I get the correct number of empty rows. What's the best way to do the actual data binding?
The script calls the web method just fine, and I can retrieve the results from the server. I can call set_dataSet(result.firstChild.children) , but all I get is a bunch of empty rows. It does apprear that I get the correct number of empty rows. What's the best way to do the actual data binding?
0
Hello Christopher,
masterTableViewInstance.set_dataSource(your collection);
masterTableViewInstance.dataBind();
will bind RadGrid on client for you. You can also check the following demo application for more details:
http://demos.telerik.com/aspnet-ajax/grid/examples/client/livedata/defaultcs.aspx
Regards,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
masterTableViewInstance.set_dataSource(your collection);
masterTableViewInstance.dataBind();
will bind RadGrid on client for you. You can also check the following demo application for more details:
http://demos.telerik.com/aspnet-ajax/grid/examples/client/livedata/defaultcs.aspx
Regards,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0

Christopher Martin
Top achievements
Rank 1
answered on 02 Oct 2009, 01:32 PM
Here's the code I'm using to load up the grid, which works just fine:
This loads the data from the web service correctly. The problem is, I get a grid full of empty rows. Here is the code I've used to create the grid:
The end result of this is a grid with the correct number of rows, but none of the rows actually display anything. there is a node in the XmlNode returned by the web service called arch_name.
Should I not be using web services that return XmlNodes? Would it be better to have the webservice return a List<T> that has the properties I want to display serialized to json, rather than the XmlNode with the ResponseType set to Xml?
I've been using the example you mentioned, and that's how I've gotten the loading and everything to work, but the problem comes when trying to get the actual data to display
function gridCreated(sender, eventArgs) { |
loadData(sender); |
} |
function loadDataCallback(result, userContext) { |
var tableView = userContext.get_masterTableView(); |
tableView.set_dataSource(result.firstChild.children); |
tableView.dataBind(); |
} |
function loadDataFailedCallback(error){ |
alert(String.Format("Load data for {0} failed.", error.get_message())); |
} |
function loadData(grid) { |
//set up the default callbacks and context for our service before calling it |
var serviceProxy = new Cadie.Bridgeworks.Services.AARMS(); |
serviceProxy.set_defaultSucceededCallback(loadDataCallback); |
serviceProxy.set_defaultFailedCallback(loadDataFailedCallback); |
serviceProxy.set_defaultUserContext(grid); |
serviceProxy.GetArchList(0, ""); |
} |
This loads the data from the web service correctly. The problem is, I get a grid full of empty rows. Here is the code I've used to create the grid:
<telerik:RadGrid ID="clientGrid" runat="server" AutoGenerateColumns="false" |
AllowPaging="true" AllowSorting="true"> |
<ClientSettings> |
<ClientEvents OnCommand="function(){}" OnGridCreated="gridCreated"/> |
</ClientSettings> |
<PagerStyle Mode="NumericPages" Position="TopAndBottom" /> |
<MasterTableView> |
<Columns> <telerik:GridBoundColumn HeaderText="Name" DataField="arch_name" /> |
</Columns> |
</MasterTableView> |
</telerik:RadGrid> |
The end result of this is a grid with the correct number of rows, but none of the rows actually display anything. there is a node in the XmlNode returned by the web service called arch_name.
Should I not be using web services that return XmlNodes? Would it be better to have the webservice return a List<T> that has the properties I want to display serialized to json, rather than the XmlNode with the ResponseType set to Xml?
I've been using the example you mentioned, and that's how I've gotten the loading and everything to work, but the problem comes when trying to get the actual data to display
0
Accepted
Hello Christopher,
Your service must return valid JSON. You can read more on the following help article:
http://www.telerik.com/help/aspnet-ajax/client-side-binding.html
Greetings,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Your service must return valid JSON. You can read more on the following help article:
http://www.telerik.com/help/aspnet-ajax/client-side-binding.html
Greetings,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0

Christopher Martin
Top achievements
Rank 1
answered on 07 Oct 2009, 01:17 PM
Thanks, I ended up re-writing the web services to return generic List<T>s and everything worked just fine.
Just so we're clear does that mean that you don't support binding at all to xml content with the grids?
Just so we're clear does that mean that you don't support binding at all to xml content with the grids?
0
Hello Christopher,
Yes RadGrid can only bind to valid JSON by using client-side data-binding. Of course you can parse the xml manually and supply RadGrid with JSON build from that xml.
Sincerely yours,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Yes RadGrid can only bind to valid JSON by using client-side data-binding. Of course you can parse the xml manually and supply RadGrid with JSON build from that xml.
Sincerely yours,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.