PDA

View Full Version : Textlink in Grid -> New Window



Snoop74
12 Oct 2010, 1:07 AM
Hello.

In my Ext.grid.GridPanel i display a textlink ("a href ...").
Now i want to open a new Ext.Window or Ext.Panel when the user is clicking on the textlink (label).

Thanks for your ideas.

Animal
12 Oct 2010, 1:30 AM
You do not need to use a hyperlink.

You will use the cellclick event, and perform your functionality in the handler.

http://dev.sencha.com/deploy/dev/docs/?class=Ext.grid.GridPanel&member=cellclick

http://www.sencha.com/learn/Ext_FAQ_Grid#Add_click_handlers_to_specific_grid_cells

Snoop74
12 Oct 2010, 4:40 AM
Hello animal.

thank you for your answer.

ok. your solution is working - but:
now the window is being shown on every click within the cell.

in the text i have 2 link-labels (a href).
isn't there a way to react on those clicks ?

Condor
12 Oct 2010, 4:46 AM
cellclick: function(grid, row, col, e) {
// check if col is correct
// next, check if e.getTarget() is on the element you want
}

Snoop74
12 Oct 2010, 4:59 AM
That's working.
Thank you conder !

Animal
12 Oct 2010, 5:47 AM
Does it work if you drag the columns into a different order?

Condor
12 Oct 2010, 6:01 AM
Indeed, don't rely on a fixed column index. Retrieve the column index from the column model using the id or dataIndex.

loiane
12 Oct 2010, 10:08 AM
You can create a renderer funcion that returns a '<a href="javascript:openExtWindow()">' for your column and create a javascript function to open the Ext.Window when user clicks on the link.

If you need, you can also pass some parameters to the function using record.data.nameOfYourColumn

Condor
13 Oct 2010, 12:02 AM
That is exactly NOT the way this should be done!

Using a cellclick listener creates lighter and more flexible code.