PDA

View Full Version : Custom Links in the Grid Cells



super_drone
30 Nov 2007, 2:03 PM
Hi All
This must be something simple but I can't seem to find an answer. I need to render links inside grid cells. Standard Links like edit/delete with ID embedded in them. I know I have to use a custom rendered in the Grid column Model. My question is how do I attach an even handler to the link in my renderer:


function custom_renderer(cell_data, meta_data, record, row_index) {
var edit_link = "<span onclick='click_handler()' id='_edit_" + record.json.id+"'>Edit</span>";
return edit_link;
}


Is above use of onclick recommended? Isn't the 'right' way to attach handlers is via addListerner? Is so, how do I first instantiate the Element so I can call addListener on it? Can I even return an Ext.Element from a renderer or I must return raw html?
There must be an example for this seemingly very common pattern - does anyone have pointers?

Thanks in advance.

super_drone
2 Dec 2007, 10:05 AM
No one?

halkon_polako
2 Dec 2007, 11:44 AM
Hi

renderers are useful to control visual aspects of the content of a cell, and always must return, as you say, raw html.

You can use CellSelectionModel or RowSelectionmodel to handle selections on a specific cell or the entire row through select events (see API documentation).

If you don't want select events, instead, you can use cellclick event or rowclick event from GridPanel object. (again , see GripPanel documentation, it gives you an example).

So, to me:
1.- use renderer to beautifully content of the cell (perhaps underlying the content to simulate a link)
2.- use ***SelectionModel or ***click events to manage the cell click

Hope this can help you.

jhontue
25 Aug 2009, 8:11 AM
Is it possible to have multiple links in the same cell ? if yes, do you have any exemple ? I couldn't handle the onClick event in alls links, only the onClick cell.