Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

334
Views
renderizar el componente javascript (ag-grid) en r shiny

Estoy tratando de incluir el ejemplo más básico de ag-grid de su sitio web en una aplicación R-shiny, a partir de ahí agregaré más y más tratando de configurar una interfaz de comunicación adecuada en la edición de datos. Sin embargo, estoy atascado en los conceptos básicos de la inclusión. El componente está incluido en el código fuente pero no se procesa:

Este es el ejemplo básico del sitio web de ag-grid: https://plnkr.co/edit/nmWxAxWONarW5gj2?p=preview%3Fp%3Dpreview&preview

Esta es mi aplicación R-Shiny

 library(shiny) library(tidyverse) ui <- fluidPage( #This tells shiny to include both css and scripts of aggrid tags$script(src="https://unpkg.com/ag-grid-community/dist/ag-grid-community.min.js"), titlePanel("Ag-Grid Basic Example"), uiOutput("myGrid") ) server <- function(input, output, session) { #This tells shiny to run our javascript file "script.js" and send it to the UI for rendering output$myGrid<- renderUI({ HTML('<script type="text/javascript", src="script.js"> </script>') }) } shinyApp(ui = ui, server = server)

donde en la carpeta www tengo script.js que es una simple copia y pegado del contenido de main.js del ejemplo vinculado anteriormente.

 const columnDefs = [ { field: "make" }, { field: "model" }, { field: "price" } ]; // specify the data const rowData = [ { make: "Toyota", model: "Celica", price: 35000 }, { make: "Ford", model: "Mondeo", price: 32000 }, { make: "Porsche", model: "Boxster", price: 72000 } ]; // let the grid know which columns and what data to use const gridOptions = { columnDefs: columnDefs, rowData: rowData }; // setup the grid after the page has finished loading document.addEventListener('DOMContentLoaded', () => { const gridDiv = document.querySelector('#myGrid'); new agGrid.Grid(gridDiv, gridOptions); });

¿Alguna pista sobre cómo proceder? Desafortunadamente, la consola no me dice nada relevante, css cdn y el script local se leen correctamente, pero por alguna razón no muestra el resultado.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

  1. No desea usar algo directamente dentro de renderUI para modificar directamente el contenedor uiOutput .
  2. El contenedor de la mesa debe tener una altura y un ancho iniciales.
  3. Dado que esto se carga después de que el documento esté listo en un evento renderUI , no se debe usar addEventListener('DOMContentLoaded' . El documento no estará listo nuevamente, por lo que este oyente no se activará.
 library(shiny) library(tidyverse) ui <- fluidPage( #This tells shiny to include both css and scripts of aggrid tags$script(src="https://unpkg.com/ag-grid-community/dist/ag-grid-community.min.js"), titlePanel("Ag-Grid Basic Example"), uiOutput("myGrid_container") ) server <- function(input, output, session) { #This tells shiny to run our javascript file "script.js" and send it to the UI for rendering output$myGrid_container<- renderUI({ tagList( div(id = "myGrid", style="height: 200px; width:500px;", class="ag-theme-alpine"), tags$script(src="script.js") ) }) } shinyApp(ui = ui, server = server)
 const columnDefs = [ { field: "make" }, { field: "model" }, { field: "price" } ]; // specify the data const rowData = [ { make: "Toyota", model: "Celica", price: 35000 }, { make: "Ford", model: "Mondeo", price: 32000 }, { make: "Porsche", model: "Boxster", price: 72000 } ]; // let the grid know which columns and what data to use const gridOptions = { columnDefs: columnDefs, rowData: rowData }; // setup the grid after the page has finished loading const gridDiv = document.querySelector('#myGrid'); new agGrid.Grid(gridDiv, gridOptions);

ingrese la descripción de la imagen aquí

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!