Type detection causing JS error
Type detection causing JS error
bluefoxreg
Posts: 12Questions: 0Answers: 0
It seems that the type detection in 1.8 doesn't properly recognize boolean data type. If the data is false, then it'll fail on line Char = sData.charAt(0); of
[code]
/*
* Function: -
* Purpose: Check to see if a string is numeric
* Returns: string:'numeric' or null
* Inputs: mixed:sText - string to check
*/
function ( sData )
[/code]
[code]
/*
* Function: -
* Purpose: Check to see if a string is numeric
* Returns: string:'numeric' or null
* Inputs: mixed:sText - string to check
*/
function ( sData )
[/code]
This discussion has been closed.
Replies
[code]
/*
* Function: _fnGetMaxLenString
* Purpose: Get the maximum strlen for each data column
* Returns: string: - max strlens for each column
* Inputs: object:oSettings - dataTables settings object
* int:iCol - column of interest
*/
function _fnGetMaxLenString( oSettings, iCol )
[/code]
Have problem dealing with none-string data.
Regards,
Allan
Allan
1. I have HTML elements that I would like to display using fnRender, but the column widths for those elements are way too big and I can't find a way to control the size to minimum. For example a checkbox would take up a huge chuck of space.
2. As I mentioned in my previous question, I'm using checkboxes, how would one maintain the checkbox state with bDeferRender set to true?
Regards,
2. You would need to have an external array which has a list of the state of all checkboxes, and use fn fnDrawCallback to then 'correct' the checkbox values based on that state array when each row is displayed.
Allan
2. I see, I was wondering if it is possible to store the checked info in the row data and the grid would simply reflect the data change?
2. I'm afraid not. That's a level of abstraction above the DataTables layer.
Allan
2. That's unfortunate, also I found another problem when I try to update row data using fnUpdate, if try to update any row that's not rendered yet, an exception is thrown on, even when I set bReraw and bAction to false.
oSettings.aoData[iRow].nTr.getElementsByTagName('td')[iVisibleColumn].innerHTML =
sDisplay;
I've also just updated fnUpdate to be able to cope with bDerferRender - thanks for the bug report!
Regards,
Allan
Allan
I do notice that there's another problem, when I have a field that's not generating a string as result
(NOTE: fnRender that returns a html string still counts as a string)
_fnGetMaxLenString will return -1 and causing the _fnGetWidestNode to return null. This causes mismatching td columns to be generated when trying to determine the column width.
Take this for example http://jsbin.com/ebodu3/
If you put a break point on
/* Build the table and 'display' it */
var nWrapper = oSettings.nTable.parentNode;
And inspect the nTr variable, you'll notice that there are 5 th in the temp table, but only 4 td in the actual table. I temporary fix my local file by replacing
if ( typeof s == 'string' && s.length > iMax )
with
if (s && s.toString().length > iMax)
in _fnGetMaxLenString, however, I'm not sure if this is the right way to properly determine the widest node.
Allan
Allan
http://jsbin.com/ohane3
Basically I make sure bUseRendered: false is set on the checkbox column (maybe bUseRendered should be default to false for any bSortable: false?) So that the actual data doesn't get changed to the checkbox string. Then I attach handlers to synchronize data with the checkboxes state. Finally to read the data, I just loop through all data and retrieve the checked items. Please let me know if there's something else I could do to minimize the hacking and/or improve performance.
Regards,
Regards,
Allan
Allan