logo

Warning: The forum is now for consultation only. Please use GitHub Discussions to post any questions or comments.


Welcome Guest ! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
scott9677  
#1 Posted : Wednesday, January 16, 2019 3:43:16 PM(UTC)
scott9677

Rank: Advanced Member

Groups: Registered
Joined: 5/18/2018(UTC)
Posts: 40

Thanks: 2 times
Is there a way to force a 'select all' for an enumerated list that is dynamically built from a database table?

If I set up a restriction and it is set for 'select all', but more records come in, the ones that were selected stay selected, but any new ones aren't added.

What I'm trying to do is default to 'select all', but allow the users to deselect options if they want to.
epf  
#2 Posted : Thursday, January 17, 2019 1:41:54 PM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 205 time(s) in 198 post(s)
Yes there is no direct option to do that (could be an option...)

However, as often, you can do it easily in JavaScript:
Select your root View, and set the property: 'Additional Javascript'

Code:
$(document).ready(function () {
    $("#0_Option_Value").selectpicker('selectAll');
});


This will do the job assuming it is the first restriction (index = 0), just change the index to match your restriction number.

scott9677  
#3 Posted : Thursday, January 17, 2019 7:10:16 PM(UTC)
scott9677

Rank: Advanced Member

Groups: Registered
Joined: 5/18/2018(UTC)
Posts: 40

Thanks: 2 times
I'll give that a shot. Can this option be thrown on the project backlog?

Edited by user Thursday, January 17, 2019 8:12:36 PM(UTC)  | Reason: Not specified

epf  
#4 Posted : Friday, January 18, 2019 7:10:32 AM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 205 time(s) in 198 post(s)
Ok, we added it in the TODO list...
j.torres@tewis.com  
#5 Posted : Friday, January 17, 2020 8:27:24 AM(UTC)
j.torres@tewis.com

Rank: Member

Groups: Registered
Joined: 4/7/2019(UTC)
Posts: 24
Man
Spain

Thanks: 7 times
Hello. Yes, it would be very useful. We're in the same situation with diferente dynamic enumerated restrictions.
The solution you suggest to workaround is not completelly functional because the javascript is not executed at the initialization of the report, but it's run with every execution, so all the values are always selected when the user executes the report and then you can not deselect values of the combo.

Thanks.

Edited by user Friday, January 17, 2020 9:01:20 AM(UTC)  | Reason: The javascript workaround is not functional.

epf  
#6 Posted : Friday, January 17, 2020 9:44:49 AM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 205 time(s) in 198 post(s)
Yes, here is the update, you have to test a JS flag to do it only for the first execution:

Code:
$(document).ready(function () {
    if (!isExecuting) {
        $("#0_Option_Value").selectpicker('selectAll');
    }
});
thanks 1 user thanked epf for this useful post.
j.torres@tewis.com on 1/17/2020(UTC)
epf  
#7 Posted : Saturday, May 2, 2020 7:12:20 AM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 205 time(s) in 198 post(s)
As you mentioned, in your email, the JavaScript method does not work if you force the execution,
thus, another way to do it is to use the 'Report Execution Init Script':

Code:

@{
    Report report = Model;
	ReportExecutionLog log = report;

    //Script executed when the report is initialized
    log.LogMessage("Executing Init Script");
    var restr = report.Models[0].Restrictions[0];
    restr.EnumValues.Clear();
    foreach (var ev in restr.EnumRE.Values) {
        restr.EnumValues.Add(ev.Id);
    }
}


This is probably safer than JavaScript and works in all cases...
Users browsing this topic
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.