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

自作多情 提交于 2019-12-08 10:28:33

问题


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:


You can use the onSelectedRowsChanged event and the getSelectedRows method.




回答2:


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);


来源:https://stackoverflow.com/questions/3086865/how-to-get-the-object-which-represents-the-selected-row-in-a-slickgrid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!