highlight and delete first row in datatable
highlight and delete first row in datatable
denizdiana
Posts: 15Questions: 8Answers: 0
Hello everyone,
I want to highlight only first row in datatable and when i click button i want to delete first row so after i delete, the second row should become first row and it should be highlighted. How can i do that? Thank you so much.
This question has accepted answers - jump to:
This discussion has been closed.
Answers
You can use the Select Extension to select the row if you like. Or you can use your own highlighting technique.
Use
row().delete()
to delete the row.The key is being able to select the first row in the table. The
row-selector
is used to select the appropriate row. To get the first row you would use a jQuery selector like this:row(':eq(0)')
.Kevin
]
And i use this method but it doesn't work.
$( dtable.row(':eq(0)')).addClass( 'highlight' );
My css method is this :
You need to use
row().node()
like this:`$( dtable.row(':eq(0)').node()).addClass( 'highlight' );
td.highlight
won't work because you are applying the class to the row not cells. Highlighting Datatables rows is a bit tricky due to its styling. See CSS tab of this example:http://live.datatables.net/sinazeca/1/edit
Kevin
Now, i have a problem with delete function
dtable.row( 0 ).delete();
this method doesnt work and it gives me "Uncaught TypeError: dtable.row(...).delete is not a function" error. What am i doing wrong?
I'm full of mistakes today
I gave the wrong link to show the highlighting:
http://live.datatables.net/sinazeca/2/edit
Also the API is
row().remove()
not delete(). See the example for remove().Kevin