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