Ignored value
Ignored value
benzittlau
Posts: 1Questions: 0Answers: 0
I would propose a change to the way type detection is currently working. In our table we would like to use the value '-' to represent blank fields. This was working fine until I attempted to implement custom type detection.
Here is the type detection block from the current _fnGatherData function:
[code]
/* Type detection */
if ( bAutoType && oSettings.aoColumns[iColumn].sType != 'string' )
{
sValType = _fnGetCellData( oSettings, iRow, iColumn, 'type' );
if ( sValType !== '' )
{
sThisType = _fnDetectType( sValType );
if ( oSettings.aoColumns[iColumn].sType === null )
{
oSettings.aoColumns[iColumn].sType = sThisType;
}
else if ( oSettings.aoColumns[iColumn].sType != sThisType &&
oSettings.aoColumns[iColumn].sType != "html" )
{
/* String is always the 'fallback' option */
oSettings.aoColumns[iColumn].sType = 'string';
}
}
}
[/code]
The way this works, it will take any value that is not a blank (the sValType !== '' check), and then will check the type for that value. If it gets conflicting results for different rows in a column, it will set the column type to string (the last else if).
This means the *only* ignored value is hardcoded to '', and that if there's value that is caught by multiple types (for example '-'), then the type detection will end up as 'string' for that column.
I would propose that instead of just checking against a blank '' value, that the ignored values for type detection should be a configurable setting that would allow for multiple ignored allows settable by the user.
Here is the type detection block from the current _fnGatherData function:
[code]
/* Type detection */
if ( bAutoType && oSettings.aoColumns[iColumn].sType != 'string' )
{
sValType = _fnGetCellData( oSettings, iRow, iColumn, 'type' );
if ( sValType !== '' )
{
sThisType = _fnDetectType( sValType );
if ( oSettings.aoColumns[iColumn].sType === null )
{
oSettings.aoColumns[iColumn].sType = sThisType;
}
else if ( oSettings.aoColumns[iColumn].sType != sThisType &&
oSettings.aoColumns[iColumn].sType != "html" )
{
/* String is always the 'fallback' option */
oSettings.aoColumns[iColumn].sType = 'string';
}
}
}
[/code]
The way this works, it will take any value that is not a blank (the sValType !== '' check), and then will check the type for that value. If it gets conflicting results for different rows in a column, it will set the column type to string (the last else if).
This means the *only* ignored value is hardcoded to '', and that if there's value that is caught by multiple types (for example '-'), then the type detection will end up as 'string' for that column.
I would propose that instead of just checking against a blank '' value, that the ignored values for type detection should be a configurable setting that would allow for multiple ignored allows settable by the user.
This discussion has been closed.
Replies
I'm not fully sure if the bUseRendered affects the type-detection, but I suspect it will.