Nested Tables
Nested Tables
menashe
Posts: 196Questions: 43Answers: 2
I use several nested tables; at least one ne has many row. If The selected row is nor within the visible window, then when I open the nested table it does not scroll to that highlighted/selected row. (If I scroll manually, the row is selected.)
I have based my nested tables on https://editor.datatables.net/examples/datatables/nested.html, and cannot see why mine do not scroll the selected row into view!
Replies
I don't have an easy way to setup the Editor nested datatable example. However you might be able to use the row().show() plugin to display the page with the selected row.
To try it add the
initComplete
option to thedatatable
config
option. IninitComplete
enable theselect
event for the nested Datatable. Something like this:Here is a working example (not nested):
https://live.datatables.net/walotamo/1/edit
Let us know if it works.
Kevin
Kevin,
I did as you suggested; assuming that I placed it correctly, I could not get it to work.
Where did you place it?
It should go in the
config
section of the field with the nested Datatable. For example:Did you install the row().show() plugin code?
Do you get errors in the browser's console?
I mentioned that I didn't have a way to test it with the Editor nested Datatable. So it might not work as I expect.
Kevin
That's where I put it. The datatable still shows at the beginning, i.e.,
The entry that is highlighted/selected (if I scroll way down) is "Merchandise - Tools".
No errors.
Perhaps, then, it does not work.
A long time ago, Allan seemed to imply that the scrolling to the selected row is built in, but that does not seem to be the case.
Any other possibilities??
And the plugin is installed. I just commented out the CDN reference the .js file, and then I did get an error.
It seems to me that if one were to implement his own nested tables--using a table variable--it woud work, because the plugin appears to work on a DataTable object.
Did you enable scrolling and turn off paging? The
row().show()
API goes to the page that contains the row returned byrow().show()
.Post your Editor filed config for the nested Datatable.
If you are using the Scroller extension then maybe you can use
row().scrollTo()
. Updated example:https://live.datatables.net/walotamo/3/edit
Kevin
If you aren't using Scroller then try using scrollIntoView to jump to the selected row. For example:
https://live.datatables.net/doloyiqa/1/edit
Kevin
Hi Kevin,
I am posting the config; I have tried every one of the suggestions--to no avail!
I was able to build a simple example:
https://live.datatables.net/guwafemu/479/edit
I realized the need to wait for the editor form to be displayed before trying to scroll to the row. I added the use of
open
to scroll to the row. The test case starts on the last page so you should be able to select an row, likeTiger
, then the edit form should scroll to that row.Kevin
Kevin,
I don't have time to implement it this moment, but... you are, as everyone says, amazing!!
I realized there is still one issue with my example. Use
editor.one()
instead ofeditor.on()
. Witheditor.on()
a new event handler will be added every time a row is edited.Updated example:
https://live.datatables.net/kemixipa/1/edit
Kevin
Kevin,
Thank you for all of your help! I saw your working example right before my eyes--but could not get it to work for me!
Then, based on your code, I remembered what you (or Allan) had suggested in terms of adjusting the column widths in a nested table.
So... I added the code to the existing handler (at the beginning) --and it works!