@(Html.Telerik().Grid<Notes>()
.Name(
"NotesGrid"
)
.Columns(columns =>
{
columns.Bound(o => o.Id).Width(100);
columns.Bound(o => o.Subject).Width(200);
columns.Bound(o => o.Date).Format(
"{0:MM/dd/yyyy}"
).Width(100);
columns.Bound(o => o.Person);
})
.DataBinding(dataBinding => dataBinding.WebService().Select(
"net.pipe://localhost:3380/NotesService.svc"
))
.Groupable()
.Sortable()
.Pageable()
.Filterable()
.Scrollable()
Controller code
public
ActionResult Index()
{
return
View();
}
WCF Code
[ServiceContract]
public
interface
INotesService
{
[OperationContract]
GridModel List(GridState state);
}
public
GridModel List(GridState state)
{
Global.Logger.Info(
"NotesService.Index()"
);
IQueryable<Notes> notes = notesRepository.DoQuery();
return
notes.ToGridModel(state);
}
9 Answers, 1 is accepted
The grid supports only HTTP WCF binding because it relies on the XMLHttpRequest object to call the service client-side. You are using different protocol ("net.pipe:") hence the problem. If you must use that protocol you should approach the problem from a different angle:
- Configure the grid for ajax binding
- In the action method which populates the grid call your WCF service (server side) and return the data.
If you need further assistance you can attach a sample project. We will modify it to demonstrate the described approach.
Regards,
Atanas Korchev
the Telerik team
Thanks for the quick response.
I have used the following databinding call as well, with no luck:
.DataBinding(dataBinding => dataBinding.WebService().Select(
"http://localhost:3380/NotesService.svc"
))
The controller method is called, but the web service method is never called. I have gotten Ajax binding working with the web service but I don't want to lose the built in sorting and filtering functionality which is why I'm trying this approach.
This is strange. What happens if you request the same URL in your browser? Is there a chance to send us a sample project? I suspect that either the URL is not accessible at all or the cross domain policy kicks in again and prevents the browser (and the grid) from requesting it via XMLHttpRequest.
Kind regards,Atanas Korchev
the Telerik team
I would ask you the same questions:
- Is the WCF service in the same domain as the MVC Application?
- Have you tried requesting the WCF url in the web browser address bar?
- Have you checked what's the server response using a tool such as IE dev toolbar or Firebug?
Providing more info or some sample code would help a lot in troubleshooting.
Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2. Yes (I get the .svc page with the wsdl link)
3. Server returns nothing
It doesn't look like the grid ever calls out to the service. All that we have on the page is an empty grid. The model works as we have the following on the same page as the grid.
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.FirstName)
</td>
Code looks something like this.
View code...
@(Html.Telerik().Grid<test2>()
.Name("Grid")
.Columns(columns =>
{
columns.Bound(o => o.FirstName);
columns.Bound(o => o.LastName);
columns.Bound(o => o.Rating);
columns.Bound(o => o.BirthDate).Format("{0:MM/dd/yyyy}");
}
)
.DataBinding(dataBinding => dataBinding.WebService().Select("http://localhost:39609/Models/ClientWcf.svc/GetClients"))
)
Controller code...
public ActionResult Index()
{
return View();
}
WCF Code...
[ServiceContract]
public interface IService1
{
[OperationContract]
GridModel GetClients(GridState state);
}
public GridModel GetClients(GridState state)
{
test2DBContext tbl = new test2DBContext();
IQueryable<test2> clients = from o in tbl.tests2
select new test2
{
FirstName= o.FirstName,
LastName= o.LastName,
Rating = o.Rating,
BirthDate= o.BirthDate
};
return clients.ToGridModel(state);
}
}
This is still considered cross domain request and will not work with the grid web service binding:
http://localhost:39609/Models/ClientWcf.svc/GetClients
The web service and your application must live in the same domain (which includes the port as well).
If possible you can try this:
dataBinding.WebService().Select("~/Models/ClientWcf.svc/GetClients"))
If not you can configure the grid for ajax binding and in your action method request the WCF service using server-side code.
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Then I suggest you try my second suggestion - to request the WCF from the server side.
The WCF binding from the client-side would work only if your WCF service is not treated as a cross domain request.
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items