Multiple Tables cause this[DataTable.ext.iApiIndex] to be undefined
Multiple Tables cause this[DataTable.ext.iApiIndex] to be undefined
gregi
Posts: 7Questions: 0Answers: 0
Hi All,
I've got a very simmilar problem like:
http://datatables.net/forums/discussion/4384/how-do-i-make-api-calls-when-using-multiple-tables/p1
I'm trying to get the selected rows from my table, which works quite nice as long I have only the first table rendered.
The second table appears in a dialog in front of the other.
I found out that the function fnGetData() fails because this[DataTable.ext.iApiIndex] returns undefined.
[code]
this.fnGetData = function( mRow, iCol )
{
var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
[/code]
Then I found the discussion above.
So, I added to my code:
[code]
$.fn.dataTableExt.iApiIndex = 1;
[/code]
Now I am wondering why it isn't changing anything.
Mycode:
[code]
function fnGetSelected(oTableLocal) {
return $(oTableLocal.selector + ' tr.row_selected');
}
function fnGetSelectedRowIDs(oTableLocal) {
oTableLocal.dataTable();
var paramsArray = new Array();
$.fn.dataTableExt.iApiIndex = 1;
$.each(fnGetSelected(oTableLocal), function (index, item) {
var rowValues = oTableLocal.fnGetData(item);
paramsArray.push({ Id: rowValues[0], Uid: rowValues[1], RowVersion: rowValues[2] });
});
return { ids: idsArr, uids: uidsArr, rowversions: rowvArr, paramsArray: paramsArray };
}
[/code]
I'm sorry, I can't make the page accessible to external users.
I've uploaded a debug dump at:
http://debug.datatables.net/esovor
Hope this helps.
Are there known issues from loading a dataTable into a JQuery dialog?
Is there any way to resolve this problem?
BTW:
Thank you, for your time and this really nice piece of software.
I've got a very simmilar problem like:
http://datatables.net/forums/discussion/4384/how-do-i-make-api-calls-when-using-multiple-tables/p1
I'm trying to get the selected rows from my table, which works quite nice as long I have only the first table rendered.
The second table appears in a dialog in front of the other.
I found out that the function fnGetData() fails because this[DataTable.ext.iApiIndex] returns undefined.
[code]
this.fnGetData = function( mRow, iCol )
{
var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
[/code]
Then I found the discussion above.
So, I added to my code:
[code]
$.fn.dataTableExt.iApiIndex = 1;
[/code]
Now I am wondering why it isn't changing anything.
Mycode:
[code]
function fnGetSelected(oTableLocal) {
return $(oTableLocal.selector + ' tr.row_selected');
}
function fnGetSelectedRowIDs(oTableLocal) {
oTableLocal.dataTable();
var paramsArray = new Array();
$.fn.dataTableExt.iApiIndex = 1;
$.each(fnGetSelected(oTableLocal), function (index, item) {
var rowValues = oTableLocal.fnGetData(item);
paramsArray.push({ Id: rowValues[0], Uid: rowValues[1], RowVersion: rowValues[2] });
});
return { ids: idsArr, uids: uidsArr, rowversions: rowvArr, paramsArray: paramsArray };
}
[/code]
I'm sorry, I can't make the page accessible to external users.
I've uploaded a debug dump at:
http://debug.datatables.net/esovor
Hope this helps.
Are there known issues from loading a dataTable into a JQuery dialog?
Is there any way to resolve this problem?
BTW:
Thank you, for your time and this really nice piece of software.
This discussion has been closed.
Replies
> $.fn.dataTableExt.iApiIndex = 1;
Are you certain the table you want to act on is in index 1? It might be easier just to use $(...).dataTable() to get references to individual tables.
Failing that, I think we'd need to we a working test page showing the issue.
Allan
I am pretty sure, because the settings at position 1 are the settings for my DataTable I try to access.
The next try was, to assign the DataTable to a local variable but it didn't change anything.
[code]
function fnGetSelectedRowIDs(oTableLocal) { // the parameter should include the DataTable or its JQuery selector
var oTableLocal = oTableLocal.dataTable(); // Contains my DataTable (I am sure it does even in error case)
var paramsArray = new Array();
//$.fn.dataTableExt.iApiIndex = 1;
$.each(fnGetSelected(oTableLocal), function (index, item) { // fnGetSelected => give a collection of my selected rows => that works.
var rowValues = oTableLocal.fnGetData(item); // if I step into fnGetData() this is my DataTable
// but it fails at (var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );) because this[anyNumber] returns undefined
// (this.length = 0) may that be the problem?
paramsArray.push({ Id: rowValues[0], Uid: rowValues[1], RowVersion: rowValues[2] });
});
return { ids: idsArr, uids: uidsArr, rowversions: rowvArr, paramsArray: paramsArray };
}
[/code]