In our Silverlight 4 application we use RIA services and the telerik Gridview control in combination with the domaindatasource and the DataPager. The user can enter filtercriterias on the grid. Furhtermore the list is paged.
We would now like to generate an excelfile depending on the filter criterias defined by the user. The workflow is the following:
1. User enters filter criterias on the grid. The user will then see a paged view of the items.
2. User pushes button to create excel report of all the data that corresponds to the entered filter criteria.
3. Serverside-> The server recieves the query with all the criterias, gets the data from the database and creates the excel file and eventually sends it back to the user.
How can i achieve this using the Gridview control in combination with the domainDatasource (on which we set the page size)?
I somehow need to get the query defined client side, ensure that there is no paging and send it back to the server. We use RIA-Services and the entity framework.
It would be great if this works.
Thanks for any help.
10 Answers, 1 is accepted
the Telerik team
Wow, you are quick. Thanks for your answer. I am not sure if you understood what i actually meant, but i guess I can defer what I need from the referenced demo. I will have register events of the gridview control, defer the loading in the domain datasource, add the filterdescriptors in the code behind, and eventually trigger loading the items.
Thanks and greetings
I just checked the example but I do not get how this shows how i can send all to filter criteria to the server. (i believe the link used to point to a different example, maybe it still exists under a different url)
My requirements are:
1. Client: Collect the filtercriteria from the paged grid (entered by the user)
2. Server: Recieve the filter criteria (but ensure that there is no paging)
3. Server: Get all rows matching the filter criteria ... (and create an excel file but this is not part of the question)
How can i do this?
Greetings and thanks in advance
You can do everything with
1. Bind RadGridView to RadDomainDataSource. Set RadDomainDataSource to AutoLoad=false.
2. If your user filters RadGridView on the client through the UI, under the hood it will transfer all of this filtering criteria to RadDomainDataSource.
3. Once you call RadDomainDataSource.Load you will perform filtering on the server and bring data back to the client which will be displayed in RadGridView.
4. If RadDomainDataSource.AutoLoad were set to true, this would happen automatically every time the user filters on the client without the need to do absolutely anything additional.
Our new Domain Data Source components ensure seamless integration between Telerik data source controls and WCF RIA Services. Now all the powerful data-shaping features of Telerik RadControls can directly translate to your domain service – filtering and sorting operations, for example, are performed directly on the server with minimum development effort. Our Domain Data Services support includes both a component that you can embed in your Silverlight page and a CollectionView Implementation that you can use in your view models for a truly MVVM-enabled scenario.
To explore the new RadDomainDataSource control in greater depth, please check itsonline examples and take a look at the following blog posts:
- Introducing RadDomainDataSource for Silverlight
- Loading data with RadDomainDataSource for Silverlight
- An MVVM Approach to Telerik Domain Services for Silverlight
- Creating CRUD application with RadDomainDataSource for Silverlight
- Why we have built RadDomainDataSource for Silverlight?
The examples are also very interesting.
I hope this helps. Greetings,
the Telerik team
Tanks for your quick answer. The links are interesting but unfortunately not exactly what i am looking for (by the way, some sample projects dont work with the latest silverlight controls)
The GridView in combination with the DomainDataSource and Ria services (and the datapager) works fine. Sorting, Filtering, Paging, everthing works the way I want it. Unfortunately, I my requirements are a little different:
1. Client side: User clicks a button
2. Client side: The filter criterias are collected (but without paging!!!)
3. Client side: The query is sent to the server (this must happen in C# code, and i cannot just call the load method-> the grid itself should not be affected or reloaded!)
4. Server side: The query is executed and a specific excel file containing the retrieved data, is created
5. Client side: The created file is downloaded
My problem is with stepp 2, 3 and 4. I need to send the query to the server (without paging) where, depending on the filter criteria, a file is created. The actual data is not (!) sent back to the client.
Unfotunately, the domain datasource does not have a property where i can access the query and then manually send to the server.
How can i achieve the desired result?
All of the currently applied filters of RadGridView are found in its FilterDescriptors collection.
You might delete the RadDomainDataSource and work directly with your DomainContext. You will have to read what FilterDescriptors RadGridView has and transfer this information to the EntityQuery of interest. This can be done by using one of our extension methods called Where:
This extension method is found in the Telerik.Windows.Controls.DomainServices assembly, in the static class called EntityQueryExtensions.
What this method does is basically, you supply a "raw" EntityQuery, for example this.yourDomainContext.GetEmployeesQuery() and a collection of FilterDescriptors, for example the RadGridView.FilterDescriptors. It will return a new EntityQuery with all the filtering information attached.
You can then load this new "filtered" EntityQuery with your DomainContext and from then on you are on your own. You can do anything on the server and the client, but that goes out of Telerik's scope and enters the WCF RIA Services domain. Same applies for the server-side generation of the excel file and its transport to the client.
I hope this helps.
the Telerik team
We don't have an example. It's pretty straightforward -- just two extension methods working on an EntityQuery.
I have explained everything in my previous post.
Let me know if you have any specific questions.
the Telerik team
I am not clear as to what to pass into the EntityQueryExtensions Where method. Are you are using this extension to create an entityquery object and passing this back through the WCF an applying this to the raw data? Any help would be appreciated. I may be way off on how to use this.
You will answer your own question if you learn about .NET Extension Methods. Please, read this before going on.
Now, you have two input things:
1. Some FilterDescriptors coming from RadGridView
2. A non-filtered EntityQuery<T> obtained from the DomainContext, i.e. this.domainContext.GetEmployeesQuery(); This is the "this" which you are "Not Clear what to Pass In"
What you need to produce is another EntityQuery<T>, but this time with some filtering information embedded. You will then send this new filtered EntityQuery to the server by using your DomainContext.
So you simply do this:
var myFilteredQuery = this.myOriginalQuery.Where(this.RadGridView.FilterDescriptors);
That's it. You then send this new filtered query to the server and you will get the filtered data back.
the Telerik team