Focal Point
[SOLVED] Adding All Option to Listbox

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/7217003576

March 26, 2015, 01:54 PM
MikeSanti
[SOLVED] Adding All Option to Listbox
Hello All,

Hope you're doing well today. I have a question which I could not find an answer to through searching.

Is it possible to give a list box (that contains data) the 'ALL' option (from HTML Composer) through html/javascript?

When the user clicks on a specific report, the listbox turns from Single Selection to Multiple Selection, and I would like to have it also feature the 'ALL' option without having to already have it set as ON in the HTML Composer.

I currently have the following function that makes the selection multiple and if any other report is selected (counter > 1) then the selection remains single selection.

function SetMultipleScenario(repid, counter)	{
     if(repid=='421' && counter == 1) {	
         lb_wi_current.multiple=true;
	lb_wi_current.addalloption="1";
     } else {
	lb_wi_current.multiple=false;
     }
}

I attempted to use the addalloption above but failed. Is it possible to modify the below code (generated from HTML Composer) in such a manner?

 <data_info checkForDuplicateValues="1" sourcetype="typeMaster" datatype="1" modifiedrequest="1" cacheruntimedata="1" dosorting="1" sorttype="1" datasource="SCENARIOS_C.mas" displayfield="SCENARIO_NAME" datafield="13SCENID_NAME" selectedvalue="" operation="OR" accept="0" addalloption="0" dynalldisplayvalue="ALL" sortorder="1">
 



Thank you for your assistance!



EDIT: 3/30/2015 (My Birthday)


Found a solution. Just had to F12 to see what the HTML was for the HTML Composer specific code and it turned out to be an < option > so manipulation was made easy through the following code:

var opt = document.createElement('option');
opt.value='_FOC_NULL';
lb_wi_current.multiple=true;
lb_wi_current.appendChild(opt);
var options = document.getElementById("lb_wi_current");
options.insertBefore(opt, lb_wi_current.options[0]);
lb_wi_current.options[0].text='ALL';

This message has been edited. Last edited by: MikeSanti,


WF 7.7.03 - W7 - HTML, PDF, EXL
March 26, 2015, 02:07 PM
MartinY
How do you build the data into your list box ? Is it loaded from a called fex ? Is it dynamic from HTML composer ?...


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
March 26, 2015, 02:25 PM
MikeSanti
quote:
Originally posted by MartinY:
How do you build the data into your list box ? Is it loaded from a called fex ? Is it dynamic from HTML composer ?...


The data is dynamic and added from an embedded procedure.


WF 7.7.03 - W7 - HTML, PDF, EXL
March 26, 2015, 02:45 PM
MartinY
If you have it called from a non-embedded procedure it would be relatively easy to call a fex that generate the data with the 'ALL' option or one without based on your selection criteria.

Or another option is to have two controls having the same position on the HTML but one with the 'ALL' option and the other without and then show or hide them according to the selection.


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
March 27, 2015, 11:04 AM
CoolGuy
Mike,

Is lb_wi_current.xxxxx something you developed or something anyone can use? I've been trying to figure out how to test what page within a portal a user is on, and depending on the page the user is on, controls within a filter.html hide/unhide or disable/enable. Do you know if this is possible?

Thanks!


8.2.02M (production), 8.2.02M (test), Windows 10, all outputs.
March 27, 2015, 01:37 PM
MikeSanti
quote:
Originally posted by MartinY:
If you have it called from a non-embedded procedure it would be relatively easy to call a fex that generate the data with the 'ALL' option or one without based on your selection criteria.

Or another option is to have two controls having the same position on the HTML but one with the 'ALL' option and the other without and then show or hide them according to the selection.


Thank you for your methods Martin. I was hoping there would be a quick and easy way, sort of like a function or something to make it so but alas, I will proceed with the fun alternative.



quote:
Originally posted by CoolGuy:
Mike,

Is lb_wi_current.xxxxx something you developed or something anyone can use? I've been trying to figure out how to test what page within a portal a user is on, and depending on the page the user is on, controls within a filter.html hide/unhide or disable/enable. Do you know if this is possible?

Thanks!


You're a pretty Cool Guy, CoolGuy.
Nothing out of the ordinary here. Anyone can use the .multiple to set it as a multiple selection or single selection (the .addalloption was me trying to see if it was built in to WebFocus).

The pages that these users go on I'm assuming will have their own separate files? Because what you're asking for is totally feasible. There may be topics that cover such through the forum already as well if you haven't tried that.


WF 7.7.03 - W7 - HTML, PDF, EXL
March 30, 2015, 02:40 PM
MikeSanti
Found a solution. Just had to F12 to see what the HTML was for the HTML Composer specific code and it turned out to be an < option > so manipulation was made easy through the following code:

var opt = document.createElement('option');
opt.value='_FOC_NULL';
lb_wi_current.multiple=true;
lb_wi_current.appendChild(opt);
var options = document.getElementById("lb_wi_current");
options.insertBefore(opt, lb_wi_current.options[0]);
lb_wi_current.options[0].text='ALL';

March 31, 2015, 09:31 AM
MartinY
Edit your first post and add [SOLVED] at the beginning of the subject


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007