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

Try to get a TotalRecords count from Table after filter

3 Answers 572 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 17 Dec 2012, 08:07 PM
Good day, I'm doing the below from code behind.  Thus far all has been working until I tried to display the Count of records that the Table is show AFTER filters are applied.  The count displayed is nowhere near the correct number so I assume I'm doing something incorrectly.


private void report1_NeedDataSource(object sender, EventArgs e)
       {
           var query = ExtendedData.GetExtendedAgreements(_db, _ProgramAreaID, null);
           table1.DataSource = query ToList();
 
           //Setup Column Filters based on Querystring, Proof of concept, to be made Dynamic
           //************************
           this.table1.Filters.AddRange(new Telerik.Reporting.Filter[] {
           new Telerik.Reporting.Filter("=Fields.Province", Telerik.Reporting.FilterOperator.Equal, "Ontario")});
 
           int count = table1.Items.Count();
 
           TotalRecords.Value = Convert.ToString(count);
       }

3 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 20 Dec 2012, 04:45 PM
Hi Tim,

The Items Property will return the report items used to create the definition of the table, e.g. TextBox items. To get the number of the filtered in data rows from table report items you can add another row with a TextBox item having the following expression:
=Count(Fields.Field_That_Appears_In_One_Of_TheColumns)
 
Hope this helps.

All the best,
Stef
the Telerik team

HAPPY WITH REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

0
Tim
Top achievements
Rank 1
answered on 20 Dec 2012, 06:15 PM
I was doing this from the code behind becuase the TotalRecords textbox is located in the footer.  When I attempt the code above, the Textbox is blank.  Is there another way?

Thx
0
Stef
Telerik team
answered on 21 Dec 2012, 05:33 PM
Hi Tim,

The approach I've described in the previous post works if the item with value is set to =Count(Fields.Field_That_Appears_In_One_Of_TheColumns) is in the table.

According to your post, I assume you have a master-detail scenario for which is normal the master to display detail data according to data. Basically if we understand your inquiry correctly, you're trying to work the other way around - display data from the detail to the master. Clearly this approach is not recommended and it will be some hack out of the right use of the report engine. I can suggest you to structure your data, so that the information you need in the master report, should be part of the master report data source.

Greetings,
Stef
the Telerik team

HAPPY WITH REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

Tags
General Discussions
Asked by
Tim
Top achievements
Rank 1
Answers by
Stef
Telerik team
Tim
Top achievements
Rank 1
Share this question
or