how to incorporate my currency jQuery table in a datatables call
how to incorporate my currency jQuery table in a datatables call
robertmazzo
Posts: 22Questions: 0Answers: 0
I currently have a jQuery function that dynamically adds rows to my Html table. My data source is XML and my code snippet is as follows :
[code]
$(this).find("exposureProfile node").each(function () {
// init my local vars here
myRow = "" + pfId + "";
myRow += "..." // add more rows to myRow var
$(myRow).appendTo("#pftable"); // APPEND TO MY HTML TABLE !!
}
[/code]
My Html table def look like:
[code]
<!-- PORTFOLIO TABLE CONTENTS ! -->
[/code]
Naturally I tried to take the easy way out by trying this, but to no avail. That is, my #pftable comes out empty :
[code]
$(document).ready(function () { // TESTING DATATABLES !!
$('#pftable').dataTable();
});
[/code]
Question is: Do I need to use the Datatables API fnAddData function to accomplish this in my .each() code above ?
Here's an example I found on http://www.datatables.net/api
[code]
// Global var for counter
var giCount = 2;
$(document).ready(function() {
$('#example').dataTable();
} );
function fnClickAddRow() {
$('#example').dataTable().fnAddData( [
giCount+".1",
giCount+".2",
giCount+".3",
giCount+".4" ]
);
giCount++;
}
[/code]
Thanks in advance for your responses.
Regards,
Bob
[code]
$(this).find("exposureProfile node").each(function () {
// init my local vars here
myRow = "" + pfId + "";
myRow += "..." // add more rows to myRow var
$(myRow).appendTo("#pftable"); // APPEND TO MY HTML TABLE !!
}
[/code]
My Html table def look like:
[code]
<!-- PORTFOLIO TABLE CONTENTS ! -->
[/code]
Naturally I tried to take the easy way out by trying this, but to no avail. That is, my #pftable comes out empty :
[code]
$(document).ready(function () { // TESTING DATATABLES !!
$('#pftable').dataTable();
});
[/code]
Question is: Do I need to use the Datatables API fnAddData function to accomplish this in my .each() code above ?
Here's an example I found on http://www.datatables.net/api
[code]
// Global var for counter
var giCount = 2;
$(document).ready(function() {
$('#example').dataTable();
} );
function fnClickAddRow() {
$('#example').dataTable().fnAddData( [
giCount+".1",
giCount+".2",
giCount+".3",
giCount+".4" ]
);
giCount++;
}
[/code]
Thanks in advance for your responses.
Regards,
Bob
This discussion has been closed.
Replies
[code]
Trade Contributions
Trade IdDescriptionContributionTermDate
[/code]
and my jQuery code worked fine and populated my table:
[code]
$('#pftable').dataTable().fnAddData([pfId, name, expType, nodeDate, term, exposure]);
[/code]
A bit slow to load, however. Perhaps i should try to pass fnAddData() the entire JSON data at once???