SlickGrid callback onRowSelect?

I want to add a callback when the user selects a row in a table, but I cannot figure out how to do this ...

Here is what I still have:

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

At the same time, I can select a row (according to this example ), but I donโ€™t know how to add a callback when rows are selected (preferably something that returns row identifiers, since I want to use them to load anything else on the page) .

Can anyone help me with this?

+2
jquery slickgrid
source share
2 answers

Ahh, looking through another code for example 6 - especially the remotemodel interaction - I see that I need to call the activated function:

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

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

+11
source share

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

+1
source share

All Articles