Я просто пытаюсь выскакивает правильная строка во всплывающем окне, и я не могу понять, как получить данные из строки просто из индекса.
Таблица данных и код. Комментарии в коде, позволяющие определить, что работает, а что нет.
Код: Выделить всё
(function($) {
var agencyFactorsTable;
ABC.page.init = function(options) {
agencyFactorsTable = $('#agencyFactorsTable').DataTable({
columnDefs: [
{ "type": "string",
"targets": [
options.groupColumnsSize,
options.groupColumnsSize + 4,
options.groupColumnsSize + 6,
options.groupColumnsSize + 7],
render: function(data, type, full, meta){
if (type === 'filter' || type === 'sort') {
var api = new $.fn.dataTable.Api(meta.settings);
var td = api.cell({row: meta.row, column: meta.col}).node();
data = $('select, input[type="text"]', td).val();
}
return data;
}
}
],
"bJQueryUI": true,
"bSortClasses": false,
"sPaginationType": "full_numbers",
"aaSorting": options.defaultOrder,
"bAutoWidth": false,
"bFilter": true,
"iDisplayLength": 10,
"dom": '',
"columns" : options.columns,
"oLanguage": EIS.settings.dataTablesLanguage,
"bProcessing": true,
"processing": true,
"bServerSide": true,
"serverSide": true,
"scrollX": true,
"scrollY": true,
"sInfo": "Showing _START_ to _TOTAL_ entries",
"ajaxSource": options.templateDataUrl,
"ajax": {
"url": options.templateDataUrl,
"dataSrc": "aaData"
}
});
$("#dialog-edit").dialog({
autoOpen: false,
modal: true,
width: 760,
height: 500,
buttons: []
});
agencyFactorsTable.on('click', 'tbody tr td img.edit_dialog', function() {
showPopup(this.parentNode);
});
function showPopup(selectedNode) {
var $source = agencyFactorsTable;
var data;
if (options.selectedRowId != null) {
// set the index hidden field
$("#selectedRowId").val(options.selectedRowId);
// get the data by index, this does not work, I get "undefined" for the value of data
data = agencyFactorsTable.row(options.selectedRowId).data(); // data = undefined
// data = agencyFactorsTable.row(options.selectedRowId); // data = _Api {0: Array{1}, length: 1, selector ...
Подробнее здесь: [url]https://stackoverflow.com/questions/78485907/getting-data-from-datatables-row-by-index[/url]