开发者

SlickGrid callback onRowSelect?

I want to add a callback when the user selects a row in the table, but I can't figure out how to do so...

Here's what I have so far:

    <script src="/js/jquery-1.4.2.min.js"></script>
    <script src="jquery-ui-1.8.8.custom.min.js"></script>
    <script src="jquery.event.drag.2.0.min.js"></script>
    <script src="slick.core.js"></script>
    <script src="slick.rowselectionmodel.js"></script>
    <script src="slick.grid.js"></script>
    <script>
        var grid;
        var columns = [ /* my column definitons */ ];
        var options = {
            enableCellNavigation: true,
            enableColumnReorder: false,
            enableAddRow: 开发者_运维知识库true
        };

        $(function() {
            $.getJSON('/actions/unit_list.php', function (data) {
                grid = new Slick.Grid("#myGrid", data, columns, options);
                grid.setSelectionModel(new Slick.RowSelectionModel());
                $('#myGrid').show();
            });
        });
    </script>

With this, I can select the row (as per this example), but I've no idea how to add a callback when the rows are selected (preferably something that returns the row id(s), since I want to use those to load something else on the page).

Can anyone help me with this?


Ahh, after reviewing more of the code on example 6--specifically the interaction of the remotemodel--I see that I have to call the triggered function like this:

grid.onSelectedRowsChanged.subscribe(function() { console.log(grid.getSelectedRows()); });

From here, I can use grid.getSelectedRows() to return the selected rows, as @Tin pointed out.


You can get selected rows by calling grid.getSelectedRows().

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜