This is a migrated thread and some comments may be shown as answers.

[Solved] Webservice Databinding with Arguments

2 Answers 72 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Shawn
Top achievements
Rank 1
Shawn asked on 08 Apr 2010, 04:12 PM
I see that when using Ajax databinding, you are able to send additional arguments to the service, however i do not see a way to send an argument to a websevice.

Is there a way to do this?  If not, this is a big time deal breaker!!

Here is my code for the grid and the webservice  I need to be able to pass the stateid to the webservice (its currently hard coded, but would need to be a parameter)



<%= Html.Telerik().Grid<BcMemProxyStub>() 
        .Name("Members"
        .HtmlAttributes( new {style = "width:805px;"}) 
        .ToolBar(commands => commands.Custom().Url("Security.mvc/MemberImport").Text("Batch Import").HtmlAttributes(new { @class = "popup" })) 
        .Columns(columns => 
        { 
            columns.Bound(m => m.MemID).Width(85) 
                .ClientTemplate("<div><a href='Security.mvc/Member/<#=MemID#>' class='popup'><#= MemID #></a></div>"); 
            columns.Bound(m => m.Login).Width(150); 
            columns.Bound(m => m.Fname).Width(150); 
            columns.Bound(m => m.Lname).Width(150); 
            columns.Bound(m => m.Memail).Width(270); 
            columns.Bound(m => m.MemID).Filterable(false).Title(" ").Width(10) 
                .ClientTemplate("<div><a href='/SiteAdmin/Models/SecurityService.svc/MemberDelete?ID=<#=MemID#>' class='action'><img border=0 src=\"/siteadmin/content/images/cancel.png\"/></a></div>"); 
        }) 
        .DataBinding(dataBinding => dataBinding.WebService().Select("~/Models/SecurityService.svc/Members")) 
        .Sortable() 
        .Pageable(paging => paging.PageSize(20)) 
        .Filterable() 
        .ClientEvents(events => events 
                    .OnDataBound("WireActionLinks"
            ) 
     
 
%> 



[OperationContract] 
        public GridModel Members(GridState state) 
        { 
            var bcms = new BcMemCollection(); 
             
            bcms.LoadByState(52);            
 
            return new BcMemCollectionProxyStub(bcms).Collection.ToGrid(state); 
        } 


2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 09 Apr 2010, 11:30 AM
Hello Shawn,

Indeed there is no easy way to supply parameters to web services now. I am attaching a new build which would make things easier. You need to use the OnDataBinding event and supply the required argument:

.ClientEvents(events => events.OnDataBinding("onDataBinding"))
%>

<script type="text/javascript">
    function onDataBinding(e) {
        e.data = { id: 52 };
    }
</script>

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.
0
Shawn
Top achievements
Rank 1
answered on 09 Apr 2010, 02:01 PM
I got around this a slightly different way:

.DataBinding(dataBinding => dataBinding.WebService().Select("~/Models/SecurityService.svc/Members?ID=" + Html.State().StateABBR))

I added it as a query parameter, which WCF doesnt seem to mind.  I am able to grab the value in the webservice this way:

var ID = HttpContext.Current.Request.QueryString["ID"];

That being said, i think i like this solution better, thanks for the newer build!

-Shawn
Tags
Grid
Asked by
Shawn
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Shawn
Top achievements
Rank 1
Share this question
or