ColReorder 1.9.1-1.9.4 -> 'this.s.aoTargets[...].x' is null or not an obj
ColReorder 1.9.1-1.9.4 -> 'this.s.aoTargets[...].x' is null or not an obj
robertbrower
Posts: 158Questions: 1Answers: 0
I tried 1.9.1 and 1.9.4 with IE8 and I get this error. It doesn't happen with FireFox.
this.s.aoTargets is being dereferenced by -1 because this.s.aoTargets.length is 0. But I do not know why. It should not be 0. I don't think I am doing anything too special.
This error happens here:
[code]
/* The insert element wasn't positioned in the array (less than operator), so we put it at
* the end
*/
if ( !bSet )
{
this.dom.pointer.style.left = this.s.aoTargets[this.s.aoTargets.length-1].x +"px";
this.s.mouse.toIndex = this.s.aoTargets[this.s.aoTargets.length-1].to;
}
[/code]
I am using this option:
[code]
, "oColReorder": {
"iFixedColumns": 7
}
[/code]
My ~initial~ column setup looks like this:
[code]
var aoColumnDefs = [
{
"aTargets": [0]
, "sTitle": "Group"
, "bSearchable": false
, "bVisible": false
}
, {
"aTargets": [1]
, "sTitle": "Name"
, "bSearchable": false
, "bVisible": false
}
, {
"aTargets": [2]
, "sTitle": "Parameter"
, "bSearchable": true
, "bVisible": true
}
, {
"aTargets": [3]
, "sTitle": "Flavor"
, "bSearchable": true
, "bVisible": true
}
, {
"aTargets": [4]
, "sTitle": "Unit"
, "bSearchable": true
, "bVisible": true
}
, {
"aTargets": [5]
, "sTitle": "Difference"
, "bSearchable": true
, "bVisible": false
, "fnRender": function (obj) {
var numRecipes = obj.oSettings.aoColumns.length - 7;
if (numRecipes < 2) {
return "N";
}
for (var i = 7; i < (7 + numRecipes); i++) {
if (i == 7) {
continue;
}
if (obj.aData[7] != obj.aData[i]) {
return "Y";
}
}
return "N";
}
, "bUseRendered": true
}
, {
"aTargets": [6]
, "sTitle": "NonEmpty"
, "bSearchable": true
, "bVisible": false
, "fnRender": function (obj) {
var numRecipes = obj.oSettings.aoColumns.length - 7;
if (numRecipes == 0) {
return "N";
}
for (var i = 7; i < (7 + numRecipes); i++) {
if ($(obj.aData[i]).text().length == 0) {
return "N";
}
}
return "Y";
}
, "bUseRendered": true
}
];
[/code]
The reason I am fixing the first 7 columns when there are only 7 columns is that I am dynamically adding columns to aaData and & aoColumnDefs and completely recreating the datatable from scratch after removing and replacing the html table. But I don't see how this would cause my problem.
If I unhide the columns which set bVisible to false, then it works. But I want some columns to be always hidden.
Can ColReorder handle hidden columns? Is iFixedColumns supposed to specify the number of fixed columns excluding hidden columns?
Thanks a lot!
Robert
this.s.aoTargets is being dereferenced by -1 because this.s.aoTargets.length is 0. But I do not know why. It should not be 0. I don't think I am doing anything too special.
This error happens here:
[code]
/* The insert element wasn't positioned in the array (less than operator), so we put it at
* the end
*/
if ( !bSet )
{
this.dom.pointer.style.left = this.s.aoTargets[this.s.aoTargets.length-1].x +"px";
this.s.mouse.toIndex = this.s.aoTargets[this.s.aoTargets.length-1].to;
}
[/code]
I am using this option:
[code]
, "oColReorder": {
"iFixedColumns": 7
}
[/code]
My ~initial~ column setup looks like this:
[code]
var aoColumnDefs = [
{
"aTargets": [0]
, "sTitle": "Group"
, "bSearchable": false
, "bVisible": false
}
, {
"aTargets": [1]
, "sTitle": "Name"
, "bSearchable": false
, "bVisible": false
}
, {
"aTargets": [2]
, "sTitle": "Parameter"
, "bSearchable": true
, "bVisible": true
}
, {
"aTargets": [3]
, "sTitle": "Flavor"
, "bSearchable": true
, "bVisible": true
}
, {
"aTargets": [4]
, "sTitle": "Unit"
, "bSearchable": true
, "bVisible": true
}
, {
"aTargets": [5]
, "sTitle": "Difference"
, "bSearchable": true
, "bVisible": false
, "fnRender": function (obj) {
var numRecipes = obj.oSettings.aoColumns.length - 7;
if (numRecipes < 2) {
return "N";
}
for (var i = 7; i < (7 + numRecipes); i++) {
if (i == 7) {
continue;
}
if (obj.aData[7] != obj.aData[i]) {
return "Y";
}
}
return "N";
}
, "bUseRendered": true
}
, {
"aTargets": [6]
, "sTitle": "NonEmpty"
, "bSearchable": true
, "bVisible": false
, "fnRender": function (obj) {
var numRecipes = obj.oSettings.aoColumns.length - 7;
if (numRecipes == 0) {
return "N";
}
for (var i = 7; i < (7 + numRecipes); i++) {
if ($(obj.aData[i]).text().length == 0) {
return "N";
}
}
return "Y";
}
, "bUseRendered": true
}
];
[/code]
The reason I am fixing the first 7 columns when there are only 7 columns is that I am dynamically adding columns to aaData and & aoColumnDefs and completely recreating the datatable from scratch after removing and replacing the html table. But I don't see how this would cause my problem.
If I unhide the columns which set bVisible to false, then it works. But I want some columns to be always hidden.
Can ColReorder handle hidden columns? Is iFixedColumns supposed to specify the number of fixed columns excluding hidden columns?
Thanks a lot!
Robert
This discussion has been closed.
Replies
It sort of fixes the problem. Is this fix planned to be rolled out?
Thanks.
Robert
Yes :-)
> Is iFixedColumns supposed to specify the number of fixed columns excluding hidden columns?
Number of fixed columns - regardless of visibility (for should a column be made visible in future, it would also need to be considered).
> It sort of fixes the problem. Is this fix planned to be rolled out?
What you say sort of fixed it - does it completely fix it?
Does this happen in my examples in IE8 (I'm afraid I don't have an IE machine to hand atm)?
Thanks,
Allan
Yes, I'm using IE8.
There are other unwanted 'side-effects' of ColReorder in my datatable. I am using fnDrawCallback to add/remove the ui-state-active class on the selected/unselected columns, and other logic to add ui-state-error to cells whose values differ from those in the selected column. (The page uses DataTables to create a Visual Diff tool), ie. It will be a late night ;)
The fnReorderCallback callback method should at least accept oldIndex, and newIndex as arguments imho. That would be very helpful to me. I guess I will try to add it and let you know.