Error setting the type of a column
Error setting the type of a column
Cesar Bravo
Posts: 5Questions: 0Answers: 0
In the version 1.5.6 of the plugin, the code for detect the column type was:
[code]
/* Attempt to auto detect the type - same as _fnGatherData() */
if ( oSettings.aoColumns[i].sType === null ) {
oSettings.aoColumns[i].sType = _fnDetectType( aData[i] );
}
else if ( oSettings.aoColumns[i].sType == "date" || oSettings.aoColumns[i].sType == "numeric" ) {
oSettings.aoColumns[i].sType = _fnDetectType( aData[i] );
}
[/code]
In version 1.6.2 has been changed for:
[code]
/* Attempt to auto detect the type - same as _fnGatherData() */
sThisType = _fnDetectType( oSettings.aoData[iThisIndex]._aData[i] );
if ( oSettings.aoColumns[i].sType === null ) {
oSettings.aoColumns[i].sType = sThisType;
}
else if ( oSettings.aoColumns[i].sType != sThisType ) {
/* String is always the 'fallback' option */
oSettings.aoColumns[i].sType = 'string';
}
[/code]
But this change is wrong because if we create a table with empty data, the detection type is numeric ¿¿?? And when we add data and detect another type, it's set to 'string' !!!!! When it should set the detected type.
[code]
/* Attempt to auto detect the type - same as _fnGatherData() */
if ( oSettings.aoColumns[i].sType === null ) {
oSettings.aoColumns[i].sType = _fnDetectType( aData[i] );
}
else if ( oSettings.aoColumns[i].sType == "date" || oSettings.aoColumns[i].sType == "numeric" ) {
oSettings.aoColumns[i].sType = _fnDetectType( aData[i] );
}
[/code]
In version 1.6.2 has been changed for:
[code]
/* Attempt to auto detect the type - same as _fnGatherData() */
sThisType = _fnDetectType( oSettings.aoData[iThisIndex]._aData[i] );
if ( oSettings.aoColumns[i].sType === null ) {
oSettings.aoColumns[i].sType = sThisType;
}
else if ( oSettings.aoColumns[i].sType != sThisType ) {
/* String is always the 'fallback' option */
oSettings.aoColumns[i].sType = 'string';
}
[/code]
But this change is wrong because if we create a table with empty data, the detection type is numeric ¿¿?? And when we add data and detect another type, it's set to 'string' !!!!! When it should set the detected type.
This discussion has been closed.
Replies
Could you post an example of this occurring please - I've haven't been able to reproduce the problem. What I tried was to take this example, http://datatables.net/examples/api/add_row.html and remove the initial row, which correctly results in sType being 'null' when the table is initialised. Then when adding a new row, the type is correctly detected as numeric, or string (when I added a character to one of the columns).
Regards,
Allan