On 03/14/2011 02:14 PM, Rich M wrote:
Hi,
I found this thread
http://tapestry.markmail.org/thread/ighytyllingci364 that referenced
overriding the grid header ala <p:someCellHeader> ...
</p:someCellHeader>, but it seems there was no response. I'm working
on overriding the headers for most of the grids in my application to
use built in search fields rather a separate search form. However,
when I override the Cell Headers the standard sorting link and icon is
understandably gone.
Does Tapestry provide any means to include the sorting back into a
Cell Header override. If not, what am I looking at in terms of
replacing it? I noticed the sort links point to the
.grid.columns:sort/<columnName> event. Can I possibly create a Link
pointing to this event with the appropriate columnName and have it
working?
I was able to create a Component that takes the columnName as a
parameter, writes out an <a> with the href pointing to
.grid.columns:sort/columnName. The <a> has a nested <img> tag that pulls
its src attribute from a getSortIcon method that returns of of three
Assets Injected into the page class corresponding to the same Tapestry
icons. Beyond seeming like a hacky component, I don't see how I can
manage the image state as it changes from sortable, ascending, and
descending since there is no event to handle on a basic <a>.
Ideally I could use an action or event link instead allowed me to handle
events and change state properly, but to do this I'd need some way of
bubbling the event through the grid.columns Sort event, and I haven't
been able to find a way to do that yet. The best idea I could come up
with was the following, but I'm not surprised it doesn't work. To my
understanding the triggerEvent will bubble up from the component to the
containing page up through any more pages.. but the Grid wouldn't be
along that path. (I replaced the <a> with a <t:eventlink> to try this,
the event fires and the icon updates, but the sort method on the grid is
never called and returnObject[0] is null).
Code:
@Inject
private ComponentResources cr;
public Object onSortClick(){
final Object[] returnObject = new Object[]{null};
Object[] ctx = new Object[]{ property };
cr.triggerEvent("sort",
ctx,
new ComponentEventCallback() {
public boolean handleResult(final Object result) {
if (result != null) {
returnObject[0] = result;
}
return result != null;
}
});
log.debug("returnObject[0]: " + returnObject[0]);
//Changes a @Persist enum that controls a switch for returning
the proper Sort Icon Asset
getNextSortState();
return returnObject[0];
}
Alternately, I'm looking at GridColumns and wonder if it is possible
to extend that Component. I'm unsure of how I would use it with a grid
though.
Worst-case scenario I'm imagining is writing an EventLink per Header
and writing custom event handlers that manipulate the data set
provided via Property to the source attribute of the Grid. That seems
messy and like a lot of work, though. I can't think of how that could
be encapsulated into a re-usable Component.
Thanks,
Rich
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org