You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Barry Books <tr...@gmail.com> on 2012/02/15 17:14:53 UTC

Sortable Mixin and possible patch to Grid

I was working in a mixin that adds jQeury sortable behavior to any
component. I have it working but my solution for the Grid component is
inelegant at best. The problem is sortable returns a sorted list of ids
from the sortable html elements. In the case of Grid that's the <tr>
elements. Currently there is no easy way to get an id on these elements so
I did this

 <t:grid t:id="thumbnails" row="thumbnail" add="edit,delete"
t:mixins="rowSorter"  rowClass="row">

to add the id I want to the rowClass, then this

public void visit(Element e) {
                                       if (
e.getName().equals(elementName)) {
                                               element = e;
                                       }
                                       if ( e.getName().equals("tr"))  {
                                               String c =
e.getAttribute("class");
                                               if ( c != null ) {

 e.forceAttributes("id",c.split(" ")[0]);
                                               }
                                       }

                               }

which copies it from the class to the id. While this works I would not call
it a good solution.

So is there any interest in a patch to Grid so you can set the tr element
id. I'm thinking it works just like the rowClass parameter but would be
called rowId. Then the tml would simply be

<t:grid t:id="thumbnails" row="thumbnail" add="edit,delete"
t:mixins="rowSorter"  rowId="row">

Barry