How To subscribe to a rowclick event of a grid

Posted by hromkes on 27-Jan-2011 03:07

Hello,

I have an object which renders as a grid.

When the user clicks on a row on the grid, I want to call a custom javascript and perform some actions with the data in the selected row.

How should I do this?

How can I determine in Javascript which row is the current row in the grid?

All Replies

Posted by sandips on 27-Jan-2011 03:21

Hello Hendrik,

Attached is sample application which will pop up alert when you select a row in grid.

Thanks,

Sandip

Posted by sandips on 27-Jan-2011 03:23

Regarding determining the selected row, i am checking if we have any OOB provision or any custom way.

Thanks,

Sandip

Posted by hromkes on 27-Jan-2011 06:55

Sandip,

Thanks for your quick reply.

Unfortunately this does not help me mech further.

In my case I have a database adapater which retruns multiple rows.

The adapter returns an object which renders as a grid.

I cannot attach events the way  you suggest.

I'm trying to connect to the Ext framework, but without success until now.

Below you'll find my code.

Attaching an event to the div containing the grid works fine.

When I want to go one step further and connect to the grid panel it does not work.

function grid_click()

{

  alert('grid_click');

}


function grid_onselect(item)

{

  alert('grid_onselect');

  alert(item.id);



function myOnReady()

{

//alert('myOnReady');

  var gridDiv = Ext.get('opleverpunten');

  var grid = Ext.Element.select('x-grid-panel',true,gridDiv);

 

  grid.on('rowclick',grid_rowclick);

  grid.on('click',grid_click);

}

Ext.onReady(myOnReady);

Posted by sandips on 27-Jan-2011 23:57

Hello Hedrik,

Can you send me your application to look into it ?

Thanks,

Sandip

This thread is closed