Expand a specific row
Expand a specific row
I have a responsive table : how I can, programmatically, expand a row that is automatically collapsed with the reduction of the screen?
I hope I explained, is a very basic need: all the rows of my table are collapsed because the screen is small; I have an id of a specific row, I want to expand this row and show the child row to render all the data therein.
I don't have to pass the data, as the examples in the documentation, because the data are already there: I just want to display data from a specific collapsed row.
How can I do? Thank You.
This question has accepted answers - jump to:
Answers
No one can help me? It seems a very easy question for who knows well DataTables and the solution can be useful to many!
This is an example:
http://test.hostingveloce.it
do not work:
var table = $ ('#tablename'). DataTable ();
var row = table.row (x);
$ (row) .Click();
do not work:
var table = $ ('# tablename'). DataTable ();
var row = table.row (x);
row.child.show ();
table.draw ();
heeeeeeelp!!!!!! ;-)
Is there anyone????? :-(
Hello robyone,
When you enable responsive mode it handles the child row management by itself, so using the
row().child
androw().child.show()
won't actually trigger anything since Responsive is handling those selector events.There might be a better way to achieve what you want, but at least using a CSS selector approach you can specifically target the row you want to "expand" like so:
I made the variables a bit elaborate since I am going to assume you will have your own way of passing the index, this way you can just substitute your own method to fill up the
targetRow
variable (which by itself is also optional).Again there might be a better way to achieve this, but my knowledge stops here :)
Hope this helps,
It works!!! Thank you very much!
Ashbjorn, I discovered that there is a problem: rows childs disturb rows counts of CSS selector!!!
In fact, in the example I published now in http://test.hostingveloce.it , if all the rows are collapsed and click on "expand row 3", line 3 expands correctly.
But if expand the line 1 or 2 by clicking the plus button and then I click on the "expand row 3", the wrong row is expanded, because the rows childs 1 or 2 disturb rows counts !!!
Is there a way to solve this problem? Thank you.
I would suggest:
You'll probably need to modify it to suit your exactly use case, but using
row().node()
would be the way I would do it myself.Allan
Great! Thank you.