0
我有一个建立在JQuery中的数据表。声明的样子:Visual Studio 2012 MVC项目的数据表
oTable =
$('#rules-datatable').dataTable({
"aoColumns": [
{ "mDataProp": [0], "sWidth": "10%" },
{ "mDataProp": [1], "sWidth": "10%" },
{ "mDataProp": [2], "sWidth": "10%" },
{ "mDataProp": [3], "sWidth": "10%" },
{ "mDataProp": [4], "sWidth": "10%" },
{ "mDataProp": [5], "sWidth": "10%" },
{ "mDataProp": [6], "sWidth": "10%" },
{ "mDataProp": [7], "sWidth": "10%" },
{ "mDataProp": [8], "sWidth": "10%" },
{ "mDataProp": [9], "sWidth": "10%" }
],
"bAutoWidth": true,
"bFilter": false,
"bLengthChange": false,
"bProcessing": true,
"bServerSide": true,
"bSort": false,
"iDisplayLength": 50,
"sAjaxSource": '@Url.Action("GetAllCapturedRules")',
"fnDrawCallback": function (oSettings) {
if (navigator.userAgent.toString().indexOf('MSIE') >= 0) {
// This fixes the IE8 overflow issue. Style is added after the datatable has been drawn.
$('#main').addClass('overflow-fix');
}
}
});
我试图点击事件之后获取所选行的值,但它似乎并没有工作。我的单击事件如下所示:
oTable.click(function() {
var anSelected = oTable.$('tr.row_selected');
if (anSelected.length == 0) {
alert('Please make a selection');
} else {
// Get data from the selected row
}
}
在它总是显示“请选择” click事件,所以它永远不会选择行的值。有人可以解释为什么,以及如何解决这个问题?我使用datables v 1.9.1