* Get the data for a given cell from the internal cache, taking into account data mapping * @param {object} settings dataTables settings object * @param {int} rowIdx aoData row id * @param {int} colIdx Column index * @param {string} type data get type ('display', 'type' 'filter|search' '
(settings, rowIdx, colIdx, type)
| 2494 | * @memberof DataTable#oApi |
| 2495 | */ |
| 2496 | function _fnGetCellData(settings, rowIdx, colIdx, type) { |
| 2497 | if (type === "search") { |
| 2498 | type = "filter" |
| 2499 | } else if (type === "order") { |
| 2500 | type = "sort" |
| 2501 | } |
| 2502 | |
| 2503 | var row = settings.aoData[rowIdx] |
| 2504 | |
| 2505 | if (!row) { |
| 2506 | return undefined |
| 2507 | } |
| 2508 | |
| 2509 | var draw = settings.iDraw |
| 2510 | var col = settings.aoColumns[colIdx] |
| 2511 | var rowData = row._aData |
| 2512 | var defaultContent = col.sDefaultContent |
| 2513 | var cellData = col.fnGetData(rowData, type, { |
| 2514 | settings: settings, |
| 2515 | row: rowIdx, |
| 2516 | col: colIdx |
| 2517 | }) |
| 2518 | |
| 2519 | // Allow for a node being returned for non-display types |
| 2520 | if (type !== "display" && cellData && typeof cellData === "object" && cellData.nodeName) { |
| 2521 | cellData = cellData.innerHTML |
| 2522 | } |
| 2523 | |
| 2524 | if (cellData === undefined) { |
| 2525 | if (settings.iDrawError != draw && defaultContent === null) { |
| 2526 | _fnLog(settings, 0, "Requested unknown parameter " + (typeof col.mData == "function" ? "{function}" : "'" + col.mData + "'") + " for row " + rowIdx + ", column " + colIdx, 4) |
| 2527 | settings.iDrawError = draw |
| 2528 | } |
| 2529 | return defaultContent |
| 2530 | } |
| 2531 | |
| 2532 | // When the data source is null and a specific data type is requested (i.e. |
| 2533 | // not the original data), we can use default column data |
| 2534 | if ((cellData === rowData || cellData === null) && defaultContent !== null && type !== undefined) { |
| 2535 | cellData = defaultContent |
| 2536 | } else if (typeof cellData === "function") { |
| 2537 | // If the data source is a function, then we run it and use the return, |
| 2538 | // executing in the scope of the data object (for instances) |
| 2539 | return cellData.call(rowData) |
| 2540 | } |
| 2541 | |
| 2542 | if (cellData === null && type === "display") { |
| 2543 | return "" |
| 2544 | } |
| 2545 | |
| 2546 | if (type === "filter") { |
| 2547 | var fomatters = DataTable.ext.type.search |
| 2548 | |
| 2549 | if (fomatters[col.sType]) { |
| 2550 | cellData = fomatters[col.sType](cellData) |
| 2551 | } |
| 2552 | } |
| 2553 |
no test coverage detected