Hi,
I am using Infragistics 2011 vol 2 JQUERY Grid. I need to bind the igGrid datasource to the datatable object available at server side .aspx.CS file.
Thanks.
Since you're using ASP.NET, you can create a web service which returns JSON, and point the grid's dataSourceUrl to the web service url. Here is an example about how to bind the grid to a WCF service:
https://www.igniteui.com/help/iggrid-getting-started-with-iggrid-odata-and-wcf-data-services
Select Sample Source File to View => RemoteBinding.html
Hope it helps. Thanks,
Angel
Hi
Thanks for reply.
I have gone through the sample. But as per the requirement we are not looking WCF service.
Is there any possiblity that i can bind JQUERY igGrid (dataSource) directly to server side function written in .CS file that returns data in JSON format.
Hello,
Actually, Dave Ward wrote this article some time ago:
http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/
I believe that it has the details you are looking for.
As for the grid, you can simply set the URL to the JSON-returning ASP page method as the grid's dataSource and you should be all set.
However, there are 2 alternative here:
1. You explicitly allow HTTP GET for this page method
or
2. Since ASP.NET defaults to using HTTP POSTs in order to ensure that your pages are secure, it won't work with the grid (or dataSource) directly as they will make GET requests to the dataSource URL (this is a design decision based on the REST standards).In that case you will need to do
$.ajax({ type: "POST", url: "http://Default.aspx/YourPageMethod", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(data) {
$("#grid").igGrid({ dataSource: data
}); } });
Angel gave you the nod to WCF services because generally they are the recommended and more beneficial way of having a "service-like" experience.
Hope this helps.Cheers,Borislav
i try this
$.ajax({ type: "POST", url: "">Default.aspx/YourPageMethod", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(data) {
its not working for me ,can i get more explanation about that plz.
If you are using the exact code that you provided, then the url has an extra quotation mark that would cause the code to fail.
If your actual code doesn't have that extra quotation mark, it will be best if you start a new thread and provide more specific details about what isn't working as you expect or what you want explained as it isn't possible to know what might be happening from just the small amount of code.