Focal Point
[CASE OPENED] IbComposer_setCurrentSelection and double-list boxes - no good

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

August 08, 2013, 11:58 AM
Francis Mariani
[CASE OPENED] IbComposer_setCurrentSelection and double-list boxes - no good
Unfortunately, HTML Composer API function IbComposer_setCurrentSelection does not add the selected values to the "to" select box in a double list box in the order specified when calling the function.

Just another weakness of this API.

This message has been edited. Last edited by: Francis Mariani,


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
August 08, 2013, 01:25 PM
J
That is correct, unfortunately. It also always adds the value to the top of your selection so that if you do something like:
 
var mySel=IbComposer_getCurrentSelection('customselect1');
mySel.push('newVal');
IbComposer_setCurrentSelection('customselect1',mySel,false);
 


You would expect the values to be something like
 
old1
old2
old3
newVal
 


Instead always it is
 
newVal
old1
old2
old3
 


No matter if you push or splice or dice or whatever...

This won't work in all situations, but you may be able to trigger the ibi onbeforeload event and mess with the arrValuesToLoad array (passed as a parameter).

Maybe your best bet is to figure out how to code this yourself...


IBI it is impossible for us to only use the controls along with the provided api to meet our customers needs. Expect us to hand code.

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


WebFOCUS 7.7.03/8.0.08
Dev Studio 7.7.03/8.0.08
App Studio 8.0.08
Windows 7
ALL Outputs
August 08, 2013, 01:56 PM
Francis Mariani
I've opened a case, but it won't really do any good - I'll have to code this myself - write a jQuery function to add the desired values in the correct order to the selectto select-box and then delete them from the selectfrom select-box - very inconvenient and very annoying.

Thanks for your feedback.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
August 08, 2013, 04:19 PM
J
I think it is odd that the select to box is single select by default (meaning you have to remove one item at a time unless you change the settings).

HAHA, the sorting doesn't work properly either. Have your double list populated by cars. Check Sort and then Sort by value ascending. Make the selected Value AUDI (all in the properties and settings).
Then have this code:
 
function onInitialUpdate() {
	var myArray = IbComposer_getCurrentSelection('customselect1');
	myArray.push('TOYOTA');
	myArray.push('JENSEN');
	IbComposer_setCurrentSelection('customselect1',myArray,false);
}
 


"Cars sorted in ascending order":
JENSEN
TOYOTA
AUDI
Confused


WebFOCUS 7.7.03/8.0.08
Dev Studio 7.7.03/8.0.08
App Studio 8.0.08
Windows 7
ALL Outputs
August 09, 2013, 09:32 AM
David Glick
Using J's example, I created this in the GA release of 8002M. I took the defaults for the double-list control and populated it using dynamic data and the CAR field from the CAR file. The IbComposer_setCurrentSelection does populate the "TO" side of the double-list control in the order of the array. If you leave the default property of "Default selection: Yes", "ALFA ROMEO" is the first value on the "TO" side. The "Sort" options are not taking effect as noted and that will be resolved as part of the open case.

In 7703, "ALFA ROMEO" is added last and that is not correct, so we will resolve that too as part of the case.


David Glick
Director WebFOCUS App Studio
and WebFOCUS Developer Studio
WebFOCUS Division
Information Builders, Inc.
Direct (917) 339-5560
Voice Mail (212) 736-6250 x3560
Fax (212) 947-5168
Email david_glick@ibi.com
August 09, 2013, 10:12 AM
J
Thanks David,

I guess while we are at it I have another bugs that we might as well cover in this case. If you have a double-list control with sorting ascending checked and you remove an option from the selectto back to the selectfrom via the button, it puts it at the bottom of the list. This happens regardless of the sorting option checked. i.e. with sorting ascending:
 
selectfr|selectto
AUDI->  |
BMW     |
JENSEN  |
...
BMW     | <- AUDI
JENSEN  |
...
BMW     |
JENSEN  |
AUDI    |
 


As you can see, the left list box is no longer in ascending order even though the left sides sorting does change depending on whether the ascending or descending option is selected.

Since this topic is about API's I have one more simple bug that would be great if it was fixed.
The IbComposer_showHtmlElement() function works great in all cases except showing an element if it is initially hidden. In fact it is only at the initial showing that it fails. Let me demonstrate (this fails for at least text spans and text boxes):
 
//This will not work if display is set to do not display for text1
function onInitialUpdate() {
	IbComposer_showHtmlElement('text1', true);
}

//This will work
function onInitialUpdate() {
	document.getElementById('text1').style.display = '';
}

//However, after the initial display, you must use IbComposer_showHtmlElement because this doesn't work:
function onInitialUpdate() {
	document.getElementById('text1').style.display = '';
	IbComposer_showHtmlElement('text1', false);
	document.getElementById('text1').style.display = '';
}

//This is what I have to end up doing
function onInitialUpdate() {
        //only for the initial display
	document.getElementById('text1').style.display = '';
	IbComposer_showHtmlElement('text1', false);

        //for the rest of the displays
	IbComposer_showHtmlElement('text1', true);
}
 


I understand this particular code isn't useful, but that same concept applies If I am hiding something based on a selection or something like that. Hopefully it is enough to reproduce the issue.


WebFOCUS 7.7.03/8.0.08
Dev Studio 7.7.03/8.0.08
App Studio 8.0.08
Windows 7
ALL Outputs
August 09, 2013, 12:40 PM
David Glick
J,

That is the same behavior I have seen on other web pages that have double-list controls. I believe they do that so that the currently moved item is readily available to be moved back if needed.


David Glick
Director WebFOCUS App Studio
and WebFOCUS Developer Studio
WebFOCUS Division
Information Builders, Inc.
Direct (917) 339-5560
Voice Mail (212) 736-6250 x3560
Fax (212) 947-5168
Email david_glick@ibi.com
August 09, 2013, 02:43 PM
J
The problem is that it isn't readily available. If you have a list box that is only a few inches tall, but you have hundreds of records (or even enough to cause scrolling), moving the item to bottom makes it appear lost (especially if everything else is sorted alphabetically).

Even if the user is already at the bottom, if there is scrolling, the item will be out of view.
Either way the item will be lost, but at least if it is alphabetical the user can find it in it's slot.

If the item is at the bottom and the user save's their selection, when they come back they may not know that they have values at the bottom (I don't know if save selection takes this into account or not).

I could add a search control so that user's can find the values, but then again for a double list control if you use the search control, it erases previously selected values that don't show up in the search.


WebFOCUS 7.7.03/8.0.08
Dev Studio 7.7.03/8.0.08
App Studio 8.0.08
Windows 7
ALL Outputs
August 12, 2013, 10:54 AM
David Glick
This is how double-list behaves on the web as far as the pages I have seen that use it. Moving an item back to the left always places it at the bottom.

Now, as far as sorting options go, my research has shown that we never sort the "To" side. There are buttons to reorder the values manually since the order may matter to the application. Automatic sorting would not allow an application to matter based on order if we sorted always.


David Glick
Director WebFOCUS App Studio
and WebFOCUS Developer Studio
WebFOCUS Division
Information Builders, Inc.
Direct (917) 339-5560
Voice Mail (212) 736-6250 x3560
Fax (212) 947-5168
Email david_glick@ibi.com
August 12, 2013, 11:25 AM
J
Alright, keeping it consistent with everything else is important... and the "To" side I totally agree to let the users sort.

Thanks for the fixes on the api functions.


WebFOCUS 7.7.03/8.0.08
Dev Studio 7.7.03/8.0.08
App Studio 8.0.08
Windows 7
ALL Outputs
August 12, 2013, 12:05 PM
Francis Mariani
quote:
In 7703, "ALFA ROMEO" is added last and that is not correct, so we will resolve that too as part of the case.

Does this mean there will be a fix for v7.7.03?


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
August 12, 2013, 12:17 PM
Francis Mariani
For now, I've worked out a convoluted method to make this work with jQuery:

    // Process selected Dimensions ---------------------------------------------------------------------
    // FM 2013/08/12 - IbComposer_setCurrentSelection does not select the options in the correct order
    // A jQuery workaround must be used
    //parent.parent.IbComposer_setCurrentSelection('P_REPORT_DIMENSIONS', P_REPORT_DIMENSIONS_array);

    // Iterate over each value in the selected Dimensions array
    $.each(P_REPORT_DIMENSIONS_array, function( intIndex, objValue ){
        // Select the option in the "from" select box of the double-list select box
        parent.parent.$("#P_REPORT_DIMENSIONS_selectfrom option[value='" + objValue + "']").attr("selected", true);
        // Determine the selected option in the "from" select box of the double-list select box
        var selectedOption = parent.parent.$('#P_REPORT_DIMENSIONS_selectfrom option:selected');
        // Add the selected option to the "to" select box of the double-list select box
        parent.parent.$('#P_REPORT_DIMENSIONS_selectto').append($(selectedOption).clone());
        // Delete the selected option from the "from" select box of the double-list select box
        $(selectedOption).remove();
    });

    // Deselect all options in the "to" select box of the double-list select box
    parent.parent.$("#P_REPORT_DIMENSIONS_selectto option").prop("selected", false);
    // Process selected Dimensions - End ---------------------------------------------------------------



Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server