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

Filter expression: how to filter a column in a table with the value from another table?

18 Answers 807 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Stargazer
Top achievements
Rank 2
Stargazer asked on 14 Dec 2009, 04:47 PM
Hello!

My scenario is as follows.

I have a report that is bound to a DataSet. That DataSet has 2 Tables, Table and Table1. In the detail section I display information from Table and have a List where I am showing data from Table1. I now want to be able to filter the data in the List, using a filter expression. The criteria I need to filter is this:

Table.Person_ID = Table1.Student_ID

Is this possible and how? I've tried with Fields.Person_ID = Fields.Student_ID and nothing...

The DataMember properties are properly defined on the report and on the list.

Any ideas?

Regards!

18 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 17 Dec 2009, 01:33 PM
Hello Stargazer,

Please examine the Product Catalog sample report available locally on your machine, especially the Filters property of the Table report item to see how it is filtered according to the current record of the main report.


Sincerely yours,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Stargazer
Top achievements
Rank 2
answered on 23 Dec 2009, 12:08 PM
Cool. Exactly what I needed.

Thanks!
0
Stargazer
Top achievements
Rank 2
answered on 16 Mar 2010, 12:45 PM
Well, it seems I'm a in a bit of a pickle here.

This turned out to resolve my issue flawlessly when the scenario is there is one CrossTab being filtered by the current record of the detail section.

Now I've had to build something like that, but with a "twist"... I now have a Detail Section, within which there is a List within which there is a table. All items are using the same data source and 2 data members. One for the Detail Section, and the other for both the list and the table inside it.

What I need is to filter the table, by the current record on the list, which is itself filtered by the current record on the detail section...

I've tried ReportItem.Parent.DataObject.<MyField> mas it gives me an exception on DataObject saying there is no object like that. Tried ReportItem.Parent.Parent.DataObject.<MyField>, but to no avail...No errors or exceptions, but no filtering also.

Any ideas on this one?

Thanks!
0
Stargazer
Top achievements
Rank 2
answered on 16 Mar 2010, 02:10 PM
Noticed one other thing... Maybe I'm not seeing this correctly.

If I hook up the DataBound event for the list, and evaluate the table inside it DataObject property, it seems to contain a row from the detail section's DataSource. Is it supposed to?

This is consistent with the filtering difficulties I'm having...
0
Steve
Telerik team
answered on 17 Mar 2010, 04:26 PM
Hi Stargazer,

Your question has already been answered in the other thread you've opened. We kindly ask you to use just one support channel to contact us. Posting the same questions numerous times slows down our response time because we will need to review and address two tickets instead of one. Moreover threads are handled according to license and time of posting, so if it is an urgent problem, we suggest you use a support ticket, which would be handled before a forum thread. Anyway here is our reply:
"If all you want is to show / hide some spacing between the groups of a table according to a specific condition, you can accomplish this quite easily by adding an empty row at the bottom of the table and applying a filter condition to the corresponding row group. The only tricky moment here is that you cannot apply a filter to a static group, so you need to make the table group dynamic first, by applying a constant grouping expression to it. To illustrate this approach better, I have created a small sample report that allows you to show / hide a blank row between the table groups according to the value of a report parameter. The attached archive file contains the sample report and a short movie that shows how the report is made. This sample requires the Q1 2010 release of Telerik Reporting to run, so we recommend you to upgrade, if you have not done so already."

If you have more questions in this regard, please do not hesitate to ask.

Greetings,
Steve
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
Ken Lewis
Top achievements
Rank 1
answered on 20 May 2010, 10:46 PM
Steve wrote:
"Please examine the Product Catalog sample report available locally on your machine, especially the Filters property of the Table report item to see how it is filtered according to the current record of the main report."

I examined that report (I'm using Q1 2010), however, there are no Filters defined for the table. Am I missing something? Is there another example I can view?

Thanks,

Ken

0
Steve
Telerik team
answered on 21 May 2010, 04:48 PM
Hi Ken,

The examples have been changed for the Q1 release to reflect all the new features that we have introduced like new data source components and in this case the bindings (you can see the full list of features in the Q1 release notes). In the modified ProductCatalog report, the table does not need to be filtered as its DataSource is set to a proper expression in the Bindings property, namely  to =ReportItem.DataObject. The DataObject of the Table gets the data from its parent - group3, which is already grouped by =Fields.ProductModel.

Regards,
Steve
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
Ken Lewis
Top achievements
Rank 1
answered on 21 May 2010, 09:55 PM
Hi Steve,

Thanks for the explanation re the Q1 release. That makes sense now and I see that the table in the catalog example does not have its own data source, but derives it from the report.

However, in my scenario I want my table to have its own data source and then filter the data "according to the current record of the main report." How do I achieve that? The data in my table is on the many side of the relationship and needs to be filtered on an ID field of the report. Is there an easy syntax for getting the ID of the current record?

Thanks again,

Ken
0
Steve
Telerik team
answered on 26 May 2010, 12:26 PM
Hi Ken,

Thanks for the clarification - in such case the approach used prior to Q1 is still valid. You can filter the table datasource based on the main report's datasource by using =ReportItem.Parent.DataObject. From here on, you can be more concrete and define the exact field you would filter upon like so:

=ReportItem.Parent.DataObject.IDFieldFromMainReport (see attached screenshot)

More info is available in the following help article as well: How-To: Add filtering to Table item and Crosstab item.

Greetings,
Steve
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
Ken Lewis
Top achievements
Rank 1
answered on 26 May 2010, 04:42 PM
Hi Steve,

Thank you very much! The detailed syntax is exactly what I needed.

I had seen that help article but there was nothing there to give me clues about using the Parent and DataObject properties. Is there somewhere else I could have found that? More examples of possible filter expressions would he helpful.

Thanks again,

Ken

0
Steve
Telerik team
answered on 26 May 2010, 04:52 PM
Hello Ken,

This information would be soon documented in details as currently there is vague mentioning of the usage of the ReportItem.

Regards,
Steve
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
Bader
Top achievements
Rank 1
answered on 15 Aug 2011, 07:25 AM
Hello,

I have the same problem. I need to filter a table by a textbox value (=Fields.TaskID).
Please view the attached screen-shots (The report designer and the table filters screen-shots).
Adding the filter doesn't help, but it cause to hide the table records (That was before adding the filter).

Note: adding the TaskID column to the table doesn't solve the problem.

Please, I need your help in order to filter the table based on the value of the task Id textbox (View screenshot, Marked on red).
It is very appreciated to send me the modified code.

Regards,
Bader
0
Steve
Telerik team
answered on 15 Aug 2011, 04:20 PM
Hello Bader,

I've attached the modified ProductCatalog that is now bound to the report data source and filtered as explained in the posts from this thread, instead of being bound through bindings. You can drop it in our online examples and run it to see it functions correctly.

Greetings,
Steve
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Bader
Top achievements
Rank 1
answered on 16 Aug 2011, 06:27 AM
Hello,

Thank you for your reply. Unfortunately the code you supported in your last post didn't work in my side (I got alot of errors, maybe because I have another version of Telerik Reporting)
Any way, In order to check what is the value that "ReportItem.Parent.DataObject.TaskID" returns, I sat one of the table columns with as "=ReportItem.Parent.DataObject.TaskID"  (Find attached iscreen-shot Report_DataObject.png) and checked the results (Find attached iscreen-shot Report_DataObject_ErrorResult.png).

Please, I need your help and explaination in order to solve the above problem.
It is very appreciated to send me a solution.

Regards,
Bader
0
Steve
Telerik team
answered on 16 Aug 2011, 02:59 PM
Hello Bader,

This is a forum thread and there is no way for us to know which version of Telerik Reporting you're using. According to your download history, the latest one you've downloaded is Q3 2009 SP1 (version 3.2.9.1211). Looking at the demo reports shipped with this version, the ProductCatalog demo report is using this very same approach I suggested i.e. you do not have to replace it with the report from my previous post, simply open it and review its implementation. I've attached a short video that shows the main points and that it runs correctly.

Regards,
Steve
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Bader
Top achievements
Rank 1
answered on 17 Aug 2011, 10:19 AM
Hello,

Thank you for your reply,
I'm sorry it is not working,

Please, I need your help in order to solve the above problem, I'm stuck in this point
It is very appreciated to send me the modified code.

Here is my code:

<removed by admin - please do not post such huge chunks of code in a forum thread>

Regards,
Bader
0
Steve
Telerik team
answered on 17 Aug 2011, 11:44 AM
Hi Bader,

In my previous post I've attached a video of the ProductCatalog demo report that you should have installed on your local machine that works as you expect, without any need of modifications. Did you try to run it and what is the result? If it runs ok, did you compare the differences to your report? Please note that having a runnable project on your end you can look into is the best way to find the culprit on your end.

If you're still having problems, please prepare a sample runnable project that exhibits the issue and attach it to a support ticket.

Best wishes,
Steve
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Bader
Top achievements
Rank 1
answered on 17 Aug 2011, 01:08 PM
Hello,

Thank you for your reply,

I submitted a new ticket: http://www.telerik.com/account/support-tickets/view-ticket.aspx?threadid=454823.

Please, I need your help,

Regards,
Bader
Tags
General Discussions
Asked by
Stargazer
Top achievements
Rank 2
Answers by
Steve
Telerik team
Stargazer
Top achievements
Rank 2
Ken Lewis
Top achievements
Rank 1
Bader
Top achievements
Rank 1
Share this question
or