Cell and Row/Column give very different results

Cell and Row/Column give very different results

andrewday17andrewday17 Posts: 4Questions: 2Answers: 0

$('#test').DataTable().row(myRow).data(). gives the actual object and not the table as per...
Object {Acct_Number: "@HENL0001/12500", Acct_Name: "Henley Business School", Status1: "CHQ", status2: "DB", status3: "4-UNINSURED"…}

Whilst 'cell' gives the actual table cell similar to node below
$('#test').DataTable().cell(myRow, 0).data()
"@HENL0001/12500"

$('#test').DataTable().row(myRow).node(0)
<tr role="row" class="odd"><td class="sorting_1">@HENL0001/12500&lt;/td><td>Henley Business School</td><td>£0.00</td><td>£77.56</td></tr>

I'm using a large object and only using a small summary of fields in a datatable, but want to access the whole object when I display the selected row in a dialog.

I don't know exactly what my data looks like before runtime ie it may have 5-8 monetary fields and several status fields too. and it can vary slightly in placement with some fields before others.

The finished app will convert a CSV import into a larger object and another heading object will control which ones are accessed.

Is there a way to select the object cell by cell using an index, and can I get a list of the key values, or should I take another approach to solving this?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,208Questions: 1Answers: 10,415 Site admin
    Answer ✓

    Hi,

    Its still morning, so my brain probably hasn't kicked in properly, but I'm afraid I'm not quite getting it.

    Do you want an array that contains the names of the object keys? Use $.map() and pass in the data object for the first row in the table: table.row(0).data(). That way you can provide a function that will only return the keys.

    Even better would be to use Object.keys(), but that isn't widely supported in browsers yet.

    Allan

  • andrewday17andrewday17 Posts: 4Questions: 2Answers: 0

    Thanks, I think that has resolved it

This discussion has been closed.