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

Pass RadGrid DataSource (dataSet)to Telerik Reporting?

4 Answers 495 Views
Grid
This is a migrated thread and some comments may be shown as answers.
phelix
Top achievements
Rank 1
phelix asked on 02 Oct 2008, 08:41 PM
Hi,

I have a RadGrid  that support sorting and filtering. The RadGrid uses untyped dataset as datasourceWhen user finish sorting and filtering,we want generate a report using the same dataset (with the same sorting order and filter criterial). One way I can think of is pass the dataset to the reporting. But how can I get the sorted and filtered dataset from the RadGrid.
Another way I think of is pass the sorting field and directions and filter criteria to the reporting and then build the sql statement to retrieve the data for the reporting. And then how can I get the current sorted fields/directions and filtered filedsand values for the RadGrid?

I personally prefer passing the sorted and filtered datasource(dataset), This way I do not need to query the database again in the report. But I suspect that the datasource(dataset) won't change for the sorting and filtering. The sorting and filtering just affect the presentation layer (how the radgrid shows the data)., isn't it? Or I can pass the dataset and then pass the sorting parms and filtering parms then do the soriting and filtering on the report.

Any suggestion? Thanks a lot
-phelix

4 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 06 Oct 2008, 02:56 PM
Hello Phelix,

Thank you for the detailed explanation.

Basically, the sort/filter criteria applied by RadGrid will be reflected in the SortExpressions collection/FilterExpression property of the master table.

Therefore, if you use the same data source for your Telerik reporting instance and define the corresponding ORDERBY and WHERE clauses (based on the values present in the SortExpressions collection/FilterExpression property of the grid) for the SELECT query you execute, you should be able to display the sorted/filtered information in reporting format.

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
phelix
Top achievements
Rank 1
answered on 07 Oct 2008, 07:44 PM
Hi,Stephen:

Thanks for the reply.

Ok, I think I will get the sort and filter criteria and build the where and order by clause for my sql statement.

But, I have problems when parse the FilterExpression. I found this thread talked about parse the filterexpression,
https://www.telerik.com/community/forums/thread/b311D-bddkdt.aspx
but How he got the operator does not sound right.
Specifically, he used single quote to get the position of operator. This line cause the OpenBrackerPos to be a negative number.
    OpenBracketPos = Conditions.IndexOf("'");

In my case,I do not have a single quote in my FilterExpression.

For example, my FilterExpression may look like:
"(it[\"first_name\"].ToString().StartsWith(\"A\")) AND (Convert.ToString(it[\"zip\"]) <> \"111\")"

Also, the datatype of zip column is System.String  and why they need to  convert it to string?

Is there a better way to parse the filterExpression, or should I loop through my RadGridcolumns to get CurrentFilterFunction.ToString() and CurrentFilterValue.ToString() for each column?

Thanks again
-phelix



0
Sebastian
Telerik team
answered on 08 Oct 2008, 07:58 AM
Hello Phelix,

Generally, you can invent your own method to parse the FilterExpression data and use it at a later stage to define the WHERE clause of the SELECT query - this depends on your custom logic and grid configuration. Therefore, you can utilize string manipulation using the methods provided by the .NET framework to achieve your goal.

Further details about how to operate with the FilterExpression property of GridTableView manually you can find in these online resources:

http://www.telerik.com/help/aspnet-ajax/grdoperatewithfilterexpression.html
http://www.telerik.com/help/aspnet-ajax/grdapplyingdefaultfilteroninitialload.html

Alternatively solution can be to iterate the grid columns and extract the CurrentFilterFunction/CurrentFilterValue properties manually as you implied.

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Steve LaForge
Top achievements
Rank 1
answered on 30 Aug 2010, 11:42 PM
I have exactly the same need!  This discussion was helpful, or at least I think it is.  I'm about to start on it but this at least let me know that I should be able to achieve my goal.  It would be really awesome if you guys added a demo of doing this!
Tags
Grid
Asked by
phelix
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
phelix
Top achievements
Rank 1
Steve LaForge
Top achievements
Rank 1
Share this question
or