Selecting specific rows while loading aaData via ajax

Selecting specific rows while loading aaData via ajax

edoarslaedoarsla Posts: 7Questions: 1Answers: 0
edited August 2013 in TableTools
Using TableTools, "sRowSelect": "multi"

I am trying to select specific rows, for which aaData contains a field "checked" set to "true".
Here's the current code:

[code]
function updateApplications(prodIds)
{
$j.ajax({
type: "GET",
url: "/GetProductSpecificElementsServlet",
dataType: 'json',
data: { instance: 'false', products: prodIds, includeCluster: true }
}).done(function(data) {

var nodes = oAppTable.fnGetAllTrNodes();

// Clear all nodes from the table
for (var i=0; i

Replies

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    The easiest option is probably to call the click function for the row:

    [code]
    $( oAppTable.fnGetNodes( rowPosition[0] ) ).click();
    [/code]

    This works because TableTools adds a click event handler to the rows in the table and triggering it will cause the row to be selected.

    The other option is to use the TableTools API to select the row - the fnSelect method in fact: http://datatables.net/extras/tabletools/api#fnSelect . You could do:

    [code]
    tableTools.fnSelect( oAppTable.fnGetNodes( rowPosition[0] ) );
    [/code]

    To get the TableTools instance you can use the fnGetInstance static method ( http://datatables.net/extras/tabletools/api#fnGetInstance ).

    DataTables 1.10 and TableTools (next) will make this a bit easier. You'll be able to do something like: `table.row.add( ... ).select();` :-).

    Regards,
    Allan
  • edoarslaedoarsla Posts: 7Questions: 1Answers: 0
    Thank you Allan, this works great.
This discussion has been closed.