开发者

How to get the object which represents the selected row in a slickgrid

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开发者_StackOverflow社区 retrive the object {id:2, name:'Iqbal', dob:'26/07/1935'} Is there a way through which I can get this object?


You can use the onSelectedRowsChanged event and the getSelectedRows method.


data[i]={
    ID: json[i].ID,
    Name: json[i].Name,
    Description: json[i].Description,
    CreatedDate: myDate,
    makesub: "---",
    shared: json[i].IsShared
    };
.....

grid.onClick = function (e, row, cell) {
            if (columns[cell].id == "colname"){ 
                        // where colname is the column on which you want to trigger the click
            alert("clicked:"+row+", albumID:"+data[row].ID);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜