Seal Report Forum
»
General
»
General Discussions/Other
»
How i can select TOP 5 or 10 records from report
Rank: Newbie
Groups: Registered
Joined: 5/31/2018(UTC) Posts: 1 Location: Hyderabad
|
I have designed a report and showing data into grid. I want to setup a filter from which user can select TOP N, and based on that want to show records from Data grid. Example. If user chooses 5, the datagrid should show only 5 records
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 12/20/2013(UTC) Posts: 1,209 Thanks: 14 times Was thanked: 206 time(s) in 199 post(s)
|
You can do that at least in 2 ways: You have first to add an input parameter as done in sample '51-User Input', named 'Nb of Records=' 1) Update the SELECT statement to add the TOP (works for SQLServer or Access) Just a a task to do this with the following code Code: ReportRestriction restriction = report.Models[0].GetRestrictionByName("Nb of Records=");
if (restriction != null && restriction.DoubleValue > 0)
{
report.Models[0].SqlSelect = string.Format("SELECT TOP {0}", restriction.DoubleValue);
}
2) The other ways is to remove the extra rows from your result data table In your model, edit the Post load Script with the following code: Code: ReportRestriction restriction = model.GetRestrictionByName("Nb of Records=");
if (restriction != null && restriction.DoubleValue > 0) {
int i = table.Rows.Count - 1;
while (i >= restriction.DoubleValue && i >= 0) {
table.Rows.RemoveAt(i);
i--;
}
}
First method is the best for performances reason, you can do it in Oracle by adding 'rownum<xx' in the restrictionText. In attachment is my sample based on the 51. 51-User input - Nb Of Records.srex (19kb) downloaded 5 time(s).
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 5/31/2018(UTC) Posts: 1 Location: Hyderabad
|
Thank you. Task is working as expected.
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 5/31/2018(UTC) Posts: 1 Location: Hyderabad
|
Hi, We used Task to provide TOP N records and it is working as expected. Now, how can we restrict user enter digits in "Nb of Records=" to 3? It should accept upto number 999(3 digits), if user enters 1000 or more(4 digits) then it should not accept. And when we set "Is required" option to "True", it is showing "*" on top of the title of that filter in Black color. Is there any way to change that * color from Black to Red? Edited by user Friday, June 15, 2018 9:31:40 AM(UTC)
| Reason: Not specified
|
|
|
|
Seal Report Forum
»
General
»
General Discussions/Other
»
How i can select TOP 5 or 10 records from report
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.