Ensure row to be visible

Ensure row to be visible

balthazarlbalthazarl Posts: 5Questions: 1Answers: 0

Hi,
how can I ensure n-th row to be visible, just after initializiusing with .DataTable(), with a client side method ?
Thanks

This question has an accepted answers - jump to answer

Answers

  • balthazarlbalthazarl Posts: 5Questions: 1Answers: 0

    I've tried with the following :

    var scroller = TableGaucheDT.fnSettings().nTable.parentNode;
    $(scroller).scrollTo('tr.selected', 1);
    

    but fnSettings is unknown.

  • balthazarlbalthazarl Posts: 5Questions: 1Answers: 0

    I Tried MaintainScrollPositionOnPostback="true" but it's not what I want to do, and after MyTable.DataTable() the scroll position is not maintained.

  • glendersonglenderson Posts: 231Questions: 11Answers: 29
    edited February 2016 Answer ✓

    I've used the jumptodata plug for this in the past.

    https://www.datatables.net/plug-ins/api/page.jumpToData()

  • balthazarlbalthazarl Posts: 5Questions: 1Answers: 0

    Thanks glenderson,
    This is not exactly what I want to do.
    Yes, It goes to the good row but displays only the selected row and the followings, not the previous.
    I Tried ScrollTo from DataTables but without any success.
    I Tried MaintainScrollPositionOnPostBack but without any success.

  • glendersonglenderson Posts: 231Questions: 11Answers: 29

    JumpToData should have repaginated if the pages changed. I then add a jquery scrollTo to bring the row into view. But, the plugin does appear to be based upon content instead of a selector. I would like to select by rowID.

    Using dataTables scrollTo seems to work only if you have scrollX implemented also, which I don't. I tried to use it but was thrown errors around lines 450 of the plugin which I assume was because I didn't have scrollbody defined because no scrollX (just a guess).

    I was looking at https://www.datatables.net/plug-ins/api/row().show() as a possible starting point for a solution and modifying it to do all the separate actions that I normally do (change page, scroll into view, highlight row). If the page changes, making the selected row appear at the "x" row would be a nice option.

    Maybe someone already has something that does it or it's already part of dataTables. It does so many things already.

  • balthazarlbalthazarl Posts: 5Questions: 1Answers: 0

    Thanks glenderson.
    I'm on holidays for a week, I will try something with .row() when return .

This discussion has been closed.