selecting rows based on column value

selecting rows based on column value

jamgamjamgam Posts: 9Questions: 3Answers: 0

I'm trying to select all the rows based on a column value. How would I go about doing this? I've tried

table.rows({search: 'value'}).data().toArray()

and a couple of other things I don't remember at this point. I know this isn't as hard as I'm making it

Answers

  • kthorngrenkthorngren Posts: 21,166Questions: 26Answers: 4,921

    By "select" do you mean highlight (select) the rows in the table or get the data?

    Your code snippet suggests you are trying to get the data. The filter() API can be used for this.

    Kevin

  • jamgamjamgam Posts: 9Questions: 3Answers: 0

    I'm trying to get the data. This is what I have now

    table.columns(4).search('Hpg').draw();
    data = table.rows({search: 'applied'}).data().toArray()

    but I'm getting rows is not defined in console

  • jamgamjamgam Posts: 9Questions: 3Answers: 0

    I'm an idiot.. this works

    table.columns(4).search('Hpg').draw();
    data = table.rows({filter: 'applied'}).data().toArray()

  • kthorngrenkthorngren Posts: 21,166Questions: 26Answers: 4,921

    I gave you only a partial answer. Here is an example that uses filter to get the row data:
    http://live.datatables.net/zesacofe/1/edit

    This way you don't need to search and update the table display to get the rows you want.

    Kevin

This discussion has been closed.