PCA-app: Pre-selecting rows in datatable in Search tab

Issue #241 resolved
Shashank Jariwala created an issue

A couple of issues with the blast_table and blast_plot have come up after a recent update of the DT library.

  • Have to pause javascript thread before the code for highlighting rows works. In server/blast_render.R :
output$blast_table <- renderDataTable({
    DT::datatable(get_blasttable(), extensions = 'Scroller', escape = FALSE,
            colnames = c("ID", "Name", "Species", "Ligands", "Score"),
            options = list(
              deferRender = TRUE,
              dom = "frtiS",
              scrollY = 200,
              scrollCollapse = TRUE
              ),
              callback = JS('
                    setTimeout(function() {
                    //window.alert("Bam!");
                    greens = document.getElementsByClassName("id_green");
                    for(var i = 0; i < greens.length; i++) {
                        row = greens[i].parentNode.parentNode;
                        row.setAttribute("class", row.getAttribute("class") + " selected");
                    }
                }, 100);
              ')
    )
})
  • blast_plot colors selected points as "green" based on which rows are selected in blast_table. Since the rows in blast_table are "selected" later, the hits above the cut-off remain red. In server/blast_render.R output$blast_plot1:
col[ as.numeric(input$blast_table_rows_selected) ] <- "green"
  • Because of the use of extension Scroller, only a few rows are rendered at a time. Scrolling couple of rows beyond the current view causes re-rendering. However, since the DT::datatable is not called, the row highlighting code is not called, which means the previously selected and highlighted rows will now be de-selected! Currently, it seems that the extension Scroller does not have a callback function when a view is re-rendered.

Comments (5)

  1. Lars Skjærven

    can we ditch the scroller extension and just go for a long table as we had once upon a time ? alternatively should we post this on stackoverflow?

  2. Barry Grant

    I would prefer the long table over the scroller extension now - sorry if I earlier lead you down this route...

  3. Lars Skjærven

    Looks good Shashank ! I have a few update to the pca-app that I will try to commit now. after that we can probably try to merge your changes into the pca-app

  4. Log in to comment