How to clean the values in one column?

How to clean the values in one column?

ZetAZetA Posts: 2Questions: 0Answers: 0
edited February 2014 in General
Hi,

I'm working on a table with a lot of rows. In this table, I have IPs Addresses, and I have to do ping (I'm using c#) to each one and put the results in the last column. I need a button to clear the results, but I dont want to call the server to re-create the table without the results.

I tried this to clear the values:

[code]$('#example td:nth-child(8)').html('');[/code]

But, it doesn't work, because, when I scroll in the table, this code only works with the first rows.
How can I clean the values in only one column?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    With DataTables 1.10's API you could do:

    [code]
    var table = $('#example').DataTable();
    table
    .rows()
    .flatten()
    .each( function (rowIdx) {
    table.cell( rowIdx, 2 ).data( '' );
    } )
    .draw();
    [/code]

    i.e. get all the rows and iterate over each, setting the data for column index 2 to be `''` .

    If you are using 1.9.4 you could probably do something similar using fnUpdate and fnGetData / fnGetNodes .

    Allan
This discussion has been closed.