fnAddData add row to JavaScript Array

fnAddData add row to JavaScript Array

jonoeoojonoeoo Posts: 4Questions: 0Answers: 0
edited October 2010 in General
Hi there,

I am getting data for my table from a JavaScript Object, and want to add a line to the object when I add data to the table. Can anyone help me out on how I would go about this. I thought about using .Append but I can't seem to work it out.

Thanks
Jonathan

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Can you just do something like "objName.whateverPropertry = '';" ? If not, perhaps you can post the code you've got at the moment?

    Allan
  • jonoeoojonoeoo Posts: 4Questions: 0Answers: 0
    Sure,

    I have [code] table.fnAddData([taskName, deviceName, image, successAction, currentDate]); [/code]

    which adds a new row to the table, but I want this to submit to the Javascript Array that im using as a data source. The array is shown below.

    [code]var HomeDataSet = [
    ['M33 Task','Satellite M33','Test 09','Auto Reboot','03 June 2010'],
    ['HP 500GB','HP EliteBook','HP EliteBook','Auto Reboot','23 June 2010']]; [/code]

    Thanks

    Jonathan
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I think I understand. DataTables will use an independent copy of the Javascript array that you feed it, not a "pointer". So if you add a row to the table, what you could do is use fnGetData() to get the full array of information that DataTables is working with. The other option would be to work with your independent copy of the array and simply do a push ( HomeDataSet.push( [ ... ] ); ).

    Allan
This discussion has been closed.