For a form in tableview, where more than one row is highlighted,
lastFS_upper = forms.student_browse.foundset.duplicateFoundSet();
aLastIndexes_upper = lastFS_upper.getSelectedIndexes();
…why, in the interactive console, does typing “aLastIndexes_upper” always return just the first highlighted row (e.g., “[2]”)?
Also, why, if I want to restore the highlights,
currentFS_upper.setSelectedIndexes(aLastIndexes_upper);
…do I get an error,
Failed to execute the method of context browse_form and name browse_recallSelection on the solution Selpa_Mgr_SQL
Wrapped java.lang.IllegalArgumentException: argument type mismatch…
The tooltip example of how to use these two commands makes no sense to me.
Thank you,
Don
Don,
foundset.duplicateFoundSet() should keep the selected indexes in multiselct mode, please file a case for that.
Also mention the argument type mismatch error, that should also be fixed.
Rob
As Rob said, please create cases for the 2 problems.
About that sample in the tooltip - it changes selection to only the first selected record of a multiple selection. It will be updated with a comment and a check for selection length.
As a workaround (until the case is fixed) for:```
foundset.setSelectedIndexes(foundset.getSelectedIndexes());
var selection = new Array();
selection = selection.concat(foundset.getSelectedIndexes());
foundset.setSelectedIndexes(selection);
Hi Andrei,
That doesn’t appear to work either. When I test the array, it indicates “[FoundSet]” in the interactive console. However, it only pastes the first highlighted row into the restored foundset.
I filed the two cases.
Thank you,
Don
Can you post the new code that you tried? (I guess it was not exactly what I suggested… that one worked for me on 6.1)
Hi Andrei,
Here’s the code section. “lastFS_upper” and “lastFS_lower” are the duplicated foundsets.
I’m using 6.0.7. I am not able to work in 6.1, too many things are broken.
Thank you,
Don
aLastIndexes_upper = new Array();
aLastIndexes_upper = aLastIndexes_upper.concat(lastFS_upper);
aLastIndexes_lower = new Array();
aLastIndexes_lower = aLastIndexes_lower.concat(lastFS_lower);
if((update_11_B) || (update_12_B) || (update_21_B) || (update_22_B)) {
if((update_11_B == false) && (update_21_B == false)) { // upper table wasn't updated
browse_setLowerFocus();
browse_showRelated();
} else if((update_12_B == false) && (update_22_B == false)) { // lower table wasn't updated
browse_setUpperFocus();
browse_showRelated();
} else { // both upper and lower table were restored --
// TODO this doesn't work, only the first selected line is restored --
if((aLastIndexes_upper) && (aLastIndexes_upper.length > 0)) {
currentFS_upper.setSelectedIndexes(aLastIndexes_upper);
}
if((aLastIndexes_lower) && (aLastIndexes_lower.length > 0)) {
currentFS_lower.setSelectedIndexes(aLastIndexes_lower);
}
//
browse_vBrowseInfo_set();
}
} else {
globals.UTIL_alertDlg("Unable to recall previous selections (context changed).","Could not recall...",null);
}
You used concat with foundset instead of foundset.getSelectedIndexes().
Try:
aLastIndexes_upper = new Array();
aLastIndexes_upper = aLastIndexes_upper.concat(lastFS_upper.getSelectedIndexes());
aLastIndexes_lower = new Array();
aLastIndexes_lower = aLastIndexes_lower.concat(lastFS_lower.getSelectedIndexes());
(...)
Hi Don,
The reported issue(s) (for get/setSelectedIndexes and also a problem which was present with duplicateFoundSet) has been fixed in Servoy 6.0.8 and 6.1.1.
Regards,
Andrei (the other Andrei
)
It works only if I move the aLastIndexes_upper and aLastIndexes_lower to the method that “remembers” the settings, where I have access to the original (not the duplicated) foundset. I cannot get the result from the duplicated foundset.
Thank you Andrei/Andrei,
Don
Don, to discuss this in an even more simple scenario, the inital code you posted:
lastFS_upper = forms.student_browse.foundset.duplicateFoundSet();
aLastIndexes_upper = lastFS_upper.getSelectedIndexes();
...
currentFS_upper.setSelectedIndexes(aLastIndexes_upper);
should work; the aLastIndexes_upper=…duplicateFoundSet().getSelectedIndexes() should return what you need (the entire array of selected indexes from the foundset) and currentFS_upper.setSelectedIndexes(aLastIndexes_upper); should set the indexes.
What is the result of …duplicateFoundSet().getSelectedIndexes() then? Do you get any error?
EDIT: the fix i did was for 6.0.8 and 6.1.1; therefore i don’t think you are able to see the results of the fix, so please ignore my above comments - everything should work fine in the next public releases mentioned
Regards,
Andrei
Yes, you are right. My workaround was only for making getSelected…/setSelected… compatible, not for the duplicate foundset part.
Until 6.0.8 you’ll just have to set selected indexes of the duplicate manually to what you get (getSelectedIndexes) from the original foundset.
Thank you Andrei/Andrei. - Don