Wizard for Chosen Multiple Selection List editor
Description
Environment
None
Web links
Activity
Carlos Ruiz August 26, 2022 at 3:37 PM
Carlos Ruiz
August 26, 2022 at 3:37 PM
just to show how can be done in case anybody need to save the list ordered
Nicolas Micoud August 26, 2022 at 3:33 PM
Nicolas Micoud
August 26, 2022 at 3:33 PM
Not sure what you have in mind there ; the code you show is just to show how it can be done ou do you want to include it?
Carlos Ruiz August 26, 2022 at 3:14 PM
Carlos Ruiz
August 26, 2022 at 3:14 PM
Maybe that can be solved adding a checkbox on the column with a label “Save ordered items” ?
No, I think is OK, the solution was really easy
public static void orderMultiFields(MRequest request) {
log.info("");
String movement = CommonHelper.orderCSV(request.get_ValueAsString("Movement"));
request.set_ValueOfColumn("Movement", movement);
String tipology = CommonHelper.orderCSV(request.get_ValueAsString("Tipology"));
request.set_ValueOfColumn("Tipology", tipology);
}
and this:
public static String orderCSV(String csvString) {
if (Util.isEmpty(csvString, true))
return csvString;
String[] values = csvString.split(",");
Arrays.sort(values);
StringBuilder ordered = new StringBuilder();
for (int i = 0; i < values.length; i++) {
ordered.append(values[i]);
if (i < values.length-1)
ordered.append(",");
}
return ordered.toString();
}
Nicolas Micoud August 26, 2022 at 3:00 PM
Nicolas Micoud
August 26, 2022 at 3:00 PM
Nicolas Micoud August 26, 2022 at 2:36 PM
Nicolas Micoud
August 26, 2022 at 2:36 PM
I have some specific cases where the order is really important (I store there some items that are displayed in a particular order elsewhere, eg: the order of columns in a grid displayed in a specific form).
Maybe that can be solved adding a checkbox on the column with a label “Save ordered items” ?
ATM, is not easy to change the order of the selected items of Chosen Multiple Selection List editors (you have to select them in the correct order).
We recently added a field and the order of items was important as it was used elsewhere.
We added a wizard for helping user to change ordering of items.
And I think is better to implement it in a generic way as the need can be for each field