mirror of
https://github.com/DataTables/DataTables.git
synced 2025-01-30 23:52:11 +01:00
Fix: DT_RowClass wasn't being updated when modified in the data source.
- This is actually a little more complex than it might first appear since any classes which have been added by DT_RowClass need to be removed. We can't just bindly remove all classes, so we need to track that classes have been added in a private variable.
This commit is contained in:
parent
4933ccf02e
commit
4cb532ad95
@ -1 +1 @@
|
||||
674d4f82869b6cbdb2158231b13297f817d8f660
|
||||
2fb2b00cc5c993827c36bc0bd768e96861c31e9c
|
||||
|
66
media/js/jquery.dataTables.js
vendored
66
media/js/jquery.dataTables.js
vendored
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
/*jslint evil: true, undef: true, browser: true */
|
||||
/*globals $,require,jQuery,define,_selector_run,_selector_opts,_selector_first,_selector_row_indexes,_ext,_Api,_api_register,_api_registerPlural,_re_new_lines,_re_html,_re_formatted_numeric,_empty,_intVal,_isNumber,_isHtml,_htmlNumeric,_pluck,_pluck_order,_range,_stripHtml,_unique,_fnBuildAjax,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnAjaxDataSrc,_fnAddColumn,_fnColumnOptions,_fnAdjustColumnSizing,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnVisbleColumns,_fnGetColumns,_fnColumnTypes,_fnApplyColumnDefs,_fnHungarianMap,_fnCamelToHungarian,_fnLanguageCompat,_fnBrowserDetect,_fnAddData,_fnAddTr,_fnNodeToDataIndex,_fnNodeToColumnIndex,_fnGetRowData,_fnGetCellData,_fnSetCellData,_fnSplitObjNotation,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnGetDataMaster,_fnClearTable,_fnDeleteIndex,_fnInvalidateRow,_fnGetRowElements,_fnCreateTr,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAddOptionsHtml,_fnDetectHeader,_fnGetUniqueThs,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnFilterCreateSearch,_fnEscapeRegex,_fnFilterData,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnInfoMacros,_fnInitialise,_fnInitComplete,_fnLengthChange,_fnFeatureHtmlLength,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnFeatureHtmlTable,_fnScrollDraw,_fnApplyToChildren,_fnCalculateColumnWidths,_fnThrottle,_fnConvertToWidth,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnScrollBarWidth,_fnSortFlatten,_fnSort,_fnSortAria,_fnSortListener,_fnSortAttachListener,_fnSortingClasses,_fnSortData,_fnSaveState,_fnLoadState,_fnSettingsFromNode,_fnLog,_fnMap,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnLengthOverflow,_fnRenderer,_fnDataSource*/
|
||||
/*globals $,require,jQuery,define,_selector_run,_selector_opts,_selector_first,_selector_row_indexes,_ext,_Api,_api_register,_api_registerPlural,_re_new_lines,_re_html,_re_formatted_numeric,_empty,_intVal,_isNumber,_isHtml,_htmlNumeric,_pluck,_pluck_order,_range,_stripHtml,_unique,_fnBuildAjax,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnAjaxDataSrc,_fnAddColumn,_fnColumnOptions,_fnAdjustColumnSizing,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnVisbleColumns,_fnGetColumns,_fnColumnTypes,_fnApplyColumnDefs,_fnHungarianMap,_fnCamelToHungarian,_fnLanguageCompat,_fnBrowserDetect,_fnAddData,_fnAddTr,_fnNodeToDataIndex,_fnNodeToColumnIndex,_fnGetRowData,_fnGetCellData,_fnSetCellData,_fnSplitObjNotation,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnGetDataMaster,_fnClearTable,_fnDeleteIndex,_fnInvalidateRow,_fnGetRowElements,_fnCreateTr,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAddOptionsHtml,_fnDetectHeader,_fnGetUniqueThs,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnFilterCreateSearch,_fnEscapeRegex,_fnFilterData,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnInfoMacros,_fnInitialise,_fnInitComplete,_fnLengthChange,_fnFeatureHtmlLength,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnFeatureHtmlTable,_fnScrollDraw,_fnApplyToChildren,_fnCalculateColumnWidths,_fnThrottle,_fnConvertToWidth,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnScrollBarWidth,_fnSortFlatten,_fnSort,_fnSortAria,_fnSortListener,_fnSortAttachListener,_fnSortingClasses,_fnSortData,_fnSaveState,_fnLoadState,_fnSettingsFromNode,_fnLog,_fnMap,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnLengthOverflow,_fnRenderer,_fnDataSource,_fnRowAttributes*/
|
||||
|
||||
(/** @lends <global> */function( window, document, $, undefined ) {
|
||||
|
||||
@ -1375,6 +1375,9 @@
|
||||
cols[i].sType = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Update DataTables special `DT_*` attributes for the row
|
||||
_fnRowAttributes( row );
|
||||
}
|
||||
|
||||
|
||||
@ -1467,26 +1470,16 @@
|
||||
{
|
||||
nTr = nTrIn || document.createElement('tr');
|
||||
|
||||
row.nTr = nTr;
|
||||
row.anCells = cells;
|
||||
|
||||
/* Use a private property on the node to allow reserve mapping from the node
|
||||
* to the aoData array for fast look up
|
||||
*/
|
||||
nTr._DT_RowIndex = iRow;
|
||||
|
||||
/* Special parameters can be given by the data source to be used on the row */
|
||||
if ( rowData.DT_RowId )
|
||||
{
|
||||
nTr.id = rowData.DT_RowId;
|
||||
}
|
||||
|
||||
if ( rowData.DT_RowClass )
|
||||
{
|
||||
nTr.className += ' '+rowData.DT_RowClass;
|
||||
}
|
||||
|
||||
if ( rowData.DT_RowData )
|
||||
{
|
||||
$(nTr).data( rowData.DT_RowData );
|
||||
}
|
||||
_fnRowAttributes( row );
|
||||
|
||||
/* Process each column */
|
||||
for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
|
||||
@ -1526,14 +1519,48 @@
|
||||
}
|
||||
}
|
||||
|
||||
row.nTr = nTr;
|
||||
row.anCells = cells;
|
||||
|
||||
_fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [nTr, rowData, iRow] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add attributes to a row based on the special `DT_*` parameters in a data
|
||||
* source object.
|
||||
* @param {object} DataTables row object for the row to be modified
|
||||
* @memberof DataTable#oApi
|
||||
*/
|
||||
function _fnRowAttributes( row )
|
||||
{
|
||||
var tr = row.nTr;
|
||||
var data = row._aData;
|
||||
|
||||
if ( tr ) {
|
||||
if ( data.DT_RowId ) {
|
||||
tr.id = data.DT_RowId;
|
||||
}
|
||||
|
||||
console.log( '_fnRowAttributes', row, data.DT_RowClass );
|
||||
if ( data.DT_RowClass ) {
|
||||
// Remove any classes added by DT_RowClass before
|
||||
var a = data.DT_RowClass.split(' ');
|
||||
row.__rowc = row.__rowc ?
|
||||
_unique( row.__rowc.concat( a ) ) :
|
||||
a;
|
||||
|
||||
console.log( row.__rowc );
|
||||
$(tr)
|
||||
.removeClass( row.__rowc.join(' ') )
|
||||
.addClass( data.DT_RowClass );
|
||||
}
|
||||
|
||||
if ( data.DT_RowData ) {
|
||||
$(tr).data( data.DT_RowData );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create the HTML header for the table
|
||||
* @param {object} oSettings dataTables settings object
|
||||
@ -5750,7 +5777,8 @@
|
||||
_fnCallbackFire: _fnCallbackFire,
|
||||
_fnLengthOverflow: _fnLengthOverflow,
|
||||
_fnRenderer: _fnRenderer,
|
||||
_fnDataSource: _fnDataSource
|
||||
_fnDataSource: _fnDataSource,
|
||||
_fnRowAttributes: _fnRowAttributes
|
||||
};
|
||||
|
||||
$.extend( DataTable.ext.internal, this.internal );
|
||||
|
Loading…
x
Reference in New Issue
Block a user