how to get data(s) under selected rows

how to get data(s) under selected rows

coreywcoreyw Posts: 6Questions: 1Answers: 0
edited March 2012 in General
Hi All,

I've got an ajax-sourced table that I needed a non-bound checkbox column in order to implement 'delete row(s)' functionality. The only way I could get the checkbox column even to appear was to create a duplicate ajax-bound column, which I later overwrite with an tag:

[code]
"aoColumns" : [
{"mDataProp": "Id", "bVisible" : false },
{ "sWidth": "25px", "sClass" : "checkbox", "mDataProp": "Id" },
{"mDataProp": "Prefix", "bVisible" : false },
{"mDataProp": "FirstName" },
{"mDataProp": "LastName" },
{"mDataProp": "Email" },
{"mDataProp": "Telephone" }
],
"fnCreatedRow" : function(nRow, aData, iDataIndex)
{
nRow.children[0].innerHTML = "";
},

"fnDrawCallback" : function()
{
jQuery("#contacts tbody tr").click(function()
{
var position = oContactTable.fnGetPosition(this);
var contact = oContactTable.fnGetData(position);
loadContactDetail(contact['Id']);
});
}
[/code]

So there's a checkbox on every row now. What I can't figure out is how to GetData for each of the selected rows:

...
var selector = '#contacts tbody tr td.checkbox input:checked:eq(' + i + ')';
var parentTD = jQuery(selector).parent(); // gets the parent TD of the INPUT
var position = oContactTable.fnGetPosition(parentTD); <- fails with a.nodeName is undefined
var contact = oContactTable.fnGetData(position[0]);

Any advice here on my approach or a workaround would be appreciated.

Corey.

Replies

  • coreywcoreyw Posts: 6Questions: 1Answers: 0
    edited March 2012
    Bleh - fixed it:

    I thought that .parent() would return a single node, but jQuery returns parent still as an array.

    So:

    var position = oContactTable.fnGetPosition(parentTD[0]);

    Fixed it.
This discussion has been closed.