SlickGrid回调onRowSelect? [英] 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>
有了这个,我可以选择行(根据这个例子),但我不知道如何在选择行时添加回调(最好是某些东西)返回行id(s),因为我想使用它们在页面上加载其他内容。)
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?
推荐答案
啊,在审查了示例6 - 特别是remotemodel的交互 - 我看到我必须像这样调用触发函数:
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()); });
从这里,我可以使用 grid.getSelectedRows()
返回选定的行,如@Tin指出的那样。
From here, I can use grid.getSelectedRows()
to return the selected rows, as @Tin pointed out.
这篇关于SlickGrid回调onRowSelect?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!