Skip to content

Commit

Permalink
Fix indexing in the presence of sorting or filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Feb 6, 2016
1 parent 7a3a5e6 commit af183fd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 0 additions & 1 deletion qgrid/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@ def _handle_qgrid_msg(self, widget, content, buffers=None):

elif content['type'] == 'selection_change':
self._selected_rows = content['rows']
print(self._selected_rows)

def get_selected_rows(self):
"""Get the currently selected rows"""
Expand Down
13 changes: 10 additions & 3 deletions qgrid/qgridjs/qgrid.widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,21 @@ define([path + "widgets/js/widget", path + "widgets/js/manager"], function(widge
// set up callbacks
sgrid.onCellChange.subscribe(function(e, args) {
var column = columns[args.cell].name;
var msg = {'row': args.row, 'column': column,
var id = args.grid.getDataItem(args.row).slick_grid_id;
var row = Number(id.replace('row', ''))
var msg = {'row': row, 'column': column,
'value': args.item[column], 'type': 'cell_change'};
that.send(msg);
});

sgrid.onSelectedRowsChanged.subscribe(function(e, args) {
var rows = args.rows;
var msg = {'rows': args.rows, 'type': 'selection_change'};
var rows = [];
var grid = args.grid;
for (var r = 0; r < args.rows.length; r++) {
var id = grid.getDataItem(args.rows[r]).slick_grid_id;
rows.push(Number(id.replace('row', '')));
}
var msg = {'rows': rows, 'type': 'selection_change'};
that.send(msg);
});
},
Expand Down

0 comments on commit af183fd

Please sign in to comment.