[
https://jira.jboss.org/jira/browse/RF-6839?page=com.atlassian.jira.plugin...
]
C. Fed commented on RF-6839:
----------------------------
I needed to have the lists maintain their order on add/remove, so I ended up modifying
ListShuttle.js in richfaces-ui-3.2.2.SR1jar. This will make every listShuttle sort this
way, which is fine in my case. Ideally a maintainOrder="true" (or split into
maintainSourceOrder and maintainTargetOrder) would be a nice attribute on listShuttle, but
I didn't have time to put together an example.
Using the regex in there worked since each row had the initial order index as part of the
ID, which I was able to strip out. I'm not sure if that's a good way to get the
index though, since that could change in a future release.
I added the following code to the bottom of the moveItem function:
var regex = /^\w*(\d+):.*$/;
for (var x = 0; x < targetComponent.shuttleTbody.rows.length - 1; x++) {
for (var y = x + 1; y < targetComponent.shuttleTbody.rows.length; y++) {
var itemX =
targetComponent.getSelectItemByNode(targetComponent.shuttleTbody.rows[x]);
var itemY =
targetComponent.getSelectItemByNode(targetComponent.shuttleTbody.rows[y]);
var orderNumX = itemX.input.value.replace(regex, '$1');
var orderNumY = itemY.input.value.replace(regex, '$1');
if (orderNumX > orderNumY) {
var parentItemNode = itemY._node.parentNode;
var tmpNode = itemX._node.nextSibling;
if (itemY._node != tmpNode) {
// Nodes are more than a position apart. Move each to the other's position
parentItemNode.insertBefore(itemX._node, itemY._node);
parentItemNode.insertBefore(itemY._node, tmpNode);
} else {
// nodes are next to each other. just move 2nd in front of 1st
parentItemNode.insertBefore(itemY._node, itemX._node);
}
}
}
}
sorting capabilities for ListShuttle component.
-----------------------------------------------
Key: RF-6839
URL:
https://jira.jboss.org/jira/browse/RF-6839
Project: RichFaces
Issue Type: Feature Request
Security Level: Public(Everyone can see)
Affects Versions: 3.3.1
Reporter: Ilya Shaikovsky
Assignee: Nick Belaevski
Fix For: Future
client side capabilities while moving items should be done with the API we will provide.
But community asked about server side properties to make lists sorted.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira