As the title.
As the title.
you can use a cell renderer (specified in the cm) and return the <a href="...>
e.g.
then in your cmCode:function emailRenderer(val) { if (val != null) { return '<a href=\'mailto:' + val + ';\'>' + val + '</a>'; } return val; }
Code:{header: "Email", width: 100, dataIndex: 'email',renderer:emailRenderer}
I know how to render a cell. But I want to do some complex things not just mailto or other simple url link when the hyper link was clicked. Should I use the renderer like this:
and invoke a javascript function.Code:return "<a href='javascript:void(0)' onclick='javascriptFunction'> " + model.get("name") + "</a>";
Any pure java solution? I am not familiar with javascript.
it really depends on what you are trying to do... if need something to click on, why not just listen to the cellselection events and work from that? there is then no need to render html that calls javascript.
btw - grid can only render html string so whilst you can put in javascript, its going to be immensely complex to plain Javascript->JSNI from GWT to work.
GXT JavaDocs: http://extjs.com/deploy/gxtdocs/
GXT FAQ & Wiki: http://extjs.com/learn/Learn_About_the_Ext_GWT_Library
Buy the Book on GXT: http://www.apress.com/book/view/9781430219408
Follow me on Twitter: http://twitter.com/gslender
The problem is the same : click listener is not fired when anchor (and inner image) is inserted in grid cell using renderer
i'e tried :
ex1:
ex2:Code:HTML h = new HTML("<a .. > ... </a>"); h.addClickListener(new ClickListener() { public void onClick(Widget sender) { // is not fired :( } }); // during rendering return h.getHTML();
ex3:Code:Hyperlink h = new Hyperlink(); h.setText("link"); h.addClickListener( /* the same */ ); // during rendering return h.getHTML();
What should i do to handle it?Code:Widget w = new Widget() { public void onBrowserEvent(Event event) { // is not fired } }; w.sinkEvents(Events.OnClick); DOM.setEventListener(image.getElement(), w);
Something similar, HTML image click in a grid.
http://ravikolli.blogspot.com/2009/0...nt-in-gxt.html
yap that is what u should be doing..
Here is my solution to this issue :
Code:// you could design column1 with a custom renderer, any hyper link or image [...] final Grid<MyItem> grid = new Grid<MyItem>(store, cm); final int indexCol = cm.findColumnIndex("column1"); grid.addListener(Events.CellClick, new Listener<BaseEvent>() { public void handleEvent(BaseEvent be) { GridEvent ge = (GridEvent) be; if (ge.colIndex == indexCol) { MyItem i = grid.getSelectionModel().getSelectedItem(); // Do stuff with My item, remove it ... store.remove(i); } } });
I have a hyperlink in a grid column. when ever i am going to clink that email link that time a new email window open with that mail id in to field? Request to please help me.