我正在尝试在 jquery 数据表上实现一个函数,该函数返回单击行的第 1 列和第 4 列
我正在关注这个例子,它允许我操作点击的行 http://datatables.net/examples/api/select_single_row.html
认为我可以更改此处理程序以执行读取单元格值程序并在我自己的逻辑上使用该值
/* Add a click handler to the rows - this could be used as a callback */
$("#example tbody").click(function(event) {
$(oTable.fnSettings().aoData).each(function (){
$(this.nTr).removeClass('row_selected');
});
$(event.target.parentNode).addClass('row_selected');
});
我也从 dataTable 论坛http://datatables.net/forums/comments.php?DiscussionID=1384&page=1#Item_0 获得了这个小代码段
$('#example tbody tr').click( function () {
// Alert the contents of an element in a SPAN in the first TD
alert( $('td:eq(0) span', this).html() );
} );
我可以有任何指针,所以我可以得到点击字段的第一列和第四列吗?
下一部分 我已经解决了上述问题,谢谢尼克
但是我有问题的下一部分。当我初始化我使用的表时
/* Init the table */
oTable = $('#filetable').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/crvWeb/jsonFileList.do",
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
}
} );
我的 servlet 采用 dir 请求参数并将列表作为 json 响应返回到数据表。
/crvWeb/jsonFileList.do
我如何添加并获得带有发布请求的 serlvet 响应,以便我可以更新我的表格?