inline editing row focus

inline editing row focus

white_rabbitwhite_rabbit Posts: 9Questions: 3Answers: 0

When i edit a row (say row number 8) and hit enter when complete the row selection returns to the first row (row number 1). Is it possible to keep the selected highlighted row on the row being edited (row number 8)?

Answers

  • kthorngrenkthorngren Posts: 21,301Questions: 26Answers: 4,946

    Datatable sorting is likely the cause of the row moving to row 1 after editing. Depending on what you are doing and how you have your code you may need to re-highlight the row after edit. Can you post a link to your page or provide a test case so we can help you?
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • white_rabbitwhite_rabbit Posts: 9Questions: 3Answers: 0

    thanks Kevin. I'm using a datatable in R shiny application and looking at live.datatables.net there doesn't seem to be a way to add code or a link for a shiny app (the app is still on my laptop and not yet on the net)

    How do you suggest I proceed? I'm keen to get some advice
    thanks
    Hugh

  • kthorngrenkthorngren Posts: 21,301Questions: 26Answers: 4,946

    Maybe you can start with posting your JS code for Datatables and Editor (assuming you are using Editor). Please use Markdown for code formatting.

    Kevin

  • white_rabbitwhite_rabbit Posts: 9Questions: 3Answers: 0

    Here's the R code I'm using:

    output$book_table <- DT::renderDT(RVTables$book %>% filter(deal==as.numeric(input$deal_choice)), selection = list(mode="single",selected=row_edited), editable = TRUE, rownames = FALSE, options=list( #drawCallback = I("function( settings ) {document.getElementById('ex1').style.width = '600px';}"), autoWidth=TRUE, ordering=FALSE, pageLength=12, scrollX = TRUE, scrollY = TRUE, bLengthChange= FALSE, searching=FALSE ) )

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    What's your Editor code? I'm not clear on what is causing the row to shift to the top - is it due to a data reorder as Kevin suggested? Can you link to a page showing the issue please?

    Allan

  • white_rabbitwhite_rabbit Posts: 9Questions: 3Answers: 0

    thanks allan, the code is in R and not on a web page so unfortunately i cant send you a link. I tried using the code below but it still doesn't work

    output$book_table <-  DT::renderDT(RVTables$book %>% 
                                           filter(deal==as.numeric(input$deal_choice)),
                                         selection = list(
                                           mode="single",
                                           selected=RVTables$row_edited
                                         ),
                                         editable = TRUE,
                                         rownames = FALSE,
                                         options=list(
                                           autoWidth=TRUE,
                                           scrollX = TRUE,
                                           ordering=FALSE,
                                           pageLength=12,
                                           scrollY = TRUE,
                                           bLengthChange= FALSE,
                                           searching=FALSE
                                         )
      )
    

    is this the correct method?

  • white_rabbitwhite_rabbit Posts: 9Questions: 3Answers: 0

    once the row has been edited I can't save the row number and set it as the focus, this is a problem when only the top 20 rows are displayed and i'm editing row 120 for example

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    I'm sorry, I don't know what would cause this off the top of my head and the information above isn't enough for me to debug it. Can you use http://live.datatables.net , JSFiddle, CodePen or similar to create a test case showing the issue, if you aren't able to link to your page. That would let me debug it and be able to offer some help.

    Allan

This discussion has been closed.