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

Client binding with parameters

5 Answers 324 Views
Grid
This is a migrated thread and some comments may be shown as answers.
William
Top achievements
Rank 1
William asked on 18 Mar 2009, 12:54 AM
Hi folks

I find myself in that annoying situation where there are lots of 'easy' examples of how to do something, but no useful real world examples.

I am wanting to use the new client side data binding in RadGrid. I have got this working using a simple method that will return data. However, I need it to accept a parameter which the user will enter onto the page. Unfortunately none of the examples show how to do this.
Here is what I have so far:
<telerik:radgrid id="radgDocuments">             
  <ClientSettings> 
    <DataBinding SelectMethod="GetLatestReportsTable" Location="~/Services/Reporting/OnDemandLatest.svc" SortParameterType="Linq" FilterParameterType="Linq"
    </DataBinding> 
  </ClientSettings> 
  <MasterTableView HierarchyLoadMode="Client" DataKeyNames="ReportSourceID" ClientDataKeyNames="ReportSourceID">..... etc 
        
Now... this works nicely. The "GetLatestReportsTable" method gets called in my WCF service and the grid fills with data.

However, I need to pass in a "ReportCategory" parameter (which the user will select from a drop down) - this will only return certain reports. I have created the method in the WCF service (UriTemplate = "/GetLatestReportsTableWParams/{ReportCategory}"). How do I actually call this on the client side? Can I do it by setting properties in the grid? Do I need to write JavaScript?

Any help appreciated!


5 Answers, 1 is accepted

Sort by
0
William
Top achievements
Rank 1
answered on 19 Mar 2009, 09:58 PM
No takers?
0
Rosen
Telerik team
answered on 20 Mar 2009, 02:28 PM
Hello William,

In order to pass additional arguments to the webservice method when using declarative client-side databinding, you should use databinding event and pass it through  the method's arguments. Please refer to this online demo for more information on the subject.

Best wishes,
Rosen
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
William
Top achievements
Rank 1
answered on 22 Mar 2009, 10:15 PM
Thanks for the reply Rosen.

Using the demo has got me closer but it still doesn't all add up (I guess there must be differences when using WCF). I am using a WCF service to supply the data. I tried to make a GetData method in the service, but it wouldn't allow me to have anything other than string params (I guess this is due to REST). Changing the params to strings then causes other problems. The closest I have got is this:
1.  Create a GetData method with no params (i.e. public List<MyObject> GetData()).
2.  On the server side get the parameter values by getting OperationContext.Current.RequestContext.RequestMessage.ToString(); and reading the values within this as Xml. This gives me the startRowIndex, maxRows, etc... and I guess I can add my own arguments in here as well.

It just strikes me as strange that I have to go to these lengths to make this work. All I want to do is pass a param in from a drop down. Using the ObjectDataSource, etc makes this easy by allowing you to bind a parameter to an object, session value, query string, etc, but with the Telerik controls this doesn't seem to be an option. Am I missing something??

Thanks again for the reply!
0
Accepted
Rosen
Telerik team
answered on 25 Mar 2009, 01:22 PM
Hi William,

I have attached a small application which demonstrates basic implementation of the desired functionality.
Please give it a spin and let us know if this helps.

Sincerely yours,
Rosen
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
William
Top achievements
Rank 1
answered on 26 Mar 2009, 12:02 AM
Hi Rosen
Thanks very much for that example! That is absolutely perfect! I think it would be good to have this put into the demos.
One of the reasons why I couldn't get it working (I think) was because I had selected to create a new WCF service, whereas I think I should have chosen to create a new Ajax Enabled WCF service.

If it hadn't been for this example I would never have got it working!
Many thanks
Will
Tags
Grid
Asked by
William
Top achievements
Rank 1
Answers by
William
Top achievements
Rank 1
Rosen
Telerik team
Share this question
or