views:

128

answers:

2

I have a webpage with a slickgrid which renders an array of objects on a grid. I want to do some dynamic stuff (a master-detail like setup) when the selected row changes. However to be able to do this, I would need the data of the selected row. I know that the grid.getCurrentCellNode() function will give me the dom element of the current node, but what I am looking for is a javascript object. For instance, if I use an array of objects like the one below

data = [ 
        {id:1, name:'Khaja', dob:'26/07/1985'},
        {id:2, name:'Iqbal', dob:'26/07/1935'}
        ......
        ...
        ];

and if my selected row is the row with id equal to 2, I want to be able to retrive the object {id:2, name:'Iqbal', dob:'26/07/1935'} Is there a way through which I can get this object?

+1  A: 

You can use the onSelectedRowsChanged event and the getSelectedRows method.

Tin
Thanks for pointing that out, I assumed that slickgrid doesn't store the original data array to grid binding, But it seems that it does. So, now I can get the selected row indexes using the `getSelectedRows` and then look up that index in the original data source. Thanks.
Khaja Minhajuddin
A: 

Sorry but I can't understand how you can get the object retrieved with getSelectedRows() method, as this method just returns the index of the selected row(s).

If the grid is about Customers, and there is the Customer ID in the first column, and the grid is sortable, how can I get it given the selected row index? How can I "look up that index in the original data source", in Khaja Minhajuddin words?

Thanx

franz976
The slickgrid API has changed considerably, You'd have a better chance of getting an answer if you post this as a separate question
Khaja Minhajuddin