Pagination is reset when using a jEditable

Pagination is reset when using a jEditable

jocapcjocapc Posts: 45Questions: 0Answers: 0
edited March 2011 in Bug reports
I think I found a problem with a DataTables when used with a JEditable plugin.
1. Go to the http://www.datatables.net/examples/api/editable.html
2. Navigate to the second or third page using navigationbutton below the table
3. Edit any cell and press ENTER

Pagination is reset and first page is shown again, so I need to navigate back to the page/cell I edited.
Is this a bug or it is possible to prevent resseting page number to the first page?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    It's because the events that jEditable adds aren't live. Therefore you need to apply jEditable on every draw (fnDrawCallback): http://datatables.net/faqs#events

    Allan
  • jocapcjocapc Posts: 45Questions: 0Answers: 0
    HI Allan,

    This is not an issue I noticed - edit event works fine on all pages.

    Problem is that when I edit a cell on the third page, and press ENTER, table is refreshed but positioned on the first page instead of the third page where I updated the cell.

    Editing works fine on all pages, and cell is updated, only problem is that user needs to use pagination to return back to the page he edited. This might be annoying if he edited 10th page and then need to return back to the page after DataTables refreshed the view to the first page.

    You can try this on your demo page http://www.datatables.net/examples/api/editable.html - just go to the third page, update any cell and table will be refreshed but positioned on the first page. Is there any way to keep the current page?

    Thanks,
    Jovan
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Ah I see - sorry - I misunderstood the issue. What I think you need is the standing redraw plug-in: http://datatables.net/plug-ins/api#fnStandingRedraw . When calling fnUpdate have it not redraw the table ( http://datatables.net/api#fnUpdate ), parameter 4, but do rebuild the data structure, parameter 5. Then call the standing redraw plug-in and you will find yourself still on the same page (actually thinking about it - try it without a redraw at all - fnUpdate will update the DOM so I think that will do what you need itself!).

    Allan
  • jocapcjocapc Posts: 45Questions: 0Answers: 0
    Thanks, that is exactly what I needed.
    I have impelemented code similar to the fnStandingRedraw and it works fine now.
  • fabattfabatt Posts: 1Questions: 0Answers: 0
    Hi all,
    for people having the same problem and work with the additional plugin
    jquery-datatables-editable (http://code.google.com/p/jquery-datatables-editable/).

    In the file jquery.dataTables.editable.js you can find the fnUpdate command in the function _fnApplyEditable. Add on both a false parameter and deactivate the invokement of _fnSetDisplayStart(); at the end of the callback funtion and it works as described by allan.

    Thank you very much allan for the provided solution it worked perfectly for me!
    It seems to be a fixed (?) bug of the jquery-datatables-editable plugin as described here: http://code.google.com/p/jquery-datatables-editable/issues/detail?id=2
  • ravialuriravialuri Posts: 1Questions: 0Answers: 0
    thanks fabatt, that worked when I updated the fnUpdate as oTable.fnUpdate(sNewCellDisplayValue, aPos[0], aPos[2],false); at ln 152 & 155
  • helmsonhelmson Posts: 1Questions: 0Answers: 0
    edited March 2012
    i don't know if i misunderstood you @ravialuri but i also had to deactivate the [code]//_fnSetDisplayStart()[/code] and that's it within the [code]_fnApplyEditable[/code] in line 165
This discussion has been closed.