JQueryで構築されたデータテーブルがあります。宣言は次のようになります。
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
}
}
クリックイベントでは常に「選択してください」と表示されるため、選択された行の値を取得することはありません。誰かが理由と、これを回避する方法を説明できますか? 私はデータブルv 1.9.1を使用しています