Cell access on selected row

Cell access on selected row

neonblueneonblue Posts: 4Questions: 2Answers: 0
edited February 2016 in DataTables 1.10

Updated... It seems the following code works when I remove the "visible".false from the code below. It looks like hiding the column also removed the variable? Also, it would be nice to access the variable by name (RSSID) vs. a fixed cell. Is that possible to do with datatables?

var FeedID = $("td:first", this).text();

I've got the following datatable:

oTable = $('#newsFeed').DataTable({
    "bProcessing": true,
    "bServerSide": true,
    "bSearchable": false,
    "sAjaxSource": 'RSSList',
    "bJQueryUI": true,
    "aoColumns": [
                    {
                        mDataProp: "RSSID", "bSortable": false, "bSearchable": false, "visible": false
                    },
                    {
                        mDataProp: "RSSName", "bSortable": false, "bSearchable": false
                    }
                 ]
});

and I've got the following click function:

$('#newsFeed tbody').on('click', 'tr', function () {
    var nTr = this.parentNode.parentNode;
    if (isOpen == '1')
    {
        oTable.fnClose(nTr);
    }
    else
    {
        /* Open this row */
        var FeedID = oTable.row('.selected',0).data();
        alert('feed ' + FeedID);
        console.log(this);
        $.get("feedList?nFeedID=" + FeedID, function (employees) {
            oTable.fnOpen(nTr, employees, 'details');
        } );
    }
});

What I want to do is access the column 'RSSID' from the selected (clicked) row. How do I do this? I've tried various forms of oTable.row... oTable.cell...

Answers

  • neonblueneonblue Posts: 4Questions: 2Answers: 0

    I'm going about this wrong. I've asked another question to work with the ID in datatables which is a much better way of handling this.

  • allanallan Posts: 63,695Questions: 1Answers: 10,500 Site admin

    I know you've move on a bit from the above, but just to round the square, you could use:

    oTable.row( this ).data().RSSID;
    

    to get the RSSID property from the row's data object.

    Allan

This discussion has been closed.