Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

216
Visualizações
Send data to a MySql DB with ajax and json using SYMFONY

I would like to be able to retrieve the data previously entered in my datagrid. However, I don't know what URL I have to put to be able to save nor how to declare this in my controller.

i'm using Handonetable.js

I have not yet created my entity

Code of the datagrid

{# ---Affichage du datagrid--- #}
  <div id="travailEquipe" class="hot mt-4"></div>
  <button id="save" class="button button--primary button--blue">Save data</button>


 <script>
{# ---Code du datagrid--- #}
    const container = document.querySelector('#travailEquipe');
    const save = document.querySelector('#save');

    const hot = new Handsontable(container,
    { data: [ ['', '',1 ,1 ,1 ,1 ,''], ['', '',1 ,1,1 ,1 ,''], ['', '',1 ,1 ,1 ,1 ,''],
    ['', '',1 ,1 ,1 ,1 ,''], ],
    className:'htCenter htMiddle', 
    colHeaders: ['Nom Apprenant', 'Prénom Apprenant','Critère A', 'Critère B', 'Critère C', 'Critère D', 'Remarque'], 
    columns: [{}, {}, { type: 'dropdown', source: [1, 2, 3, 4] }, { type: 'dropdown',
    source: [1, 2, 3, 4] },
     { type: 'dropdown', source: [1, 2, 3, 4] }, 
     { type:'dropdown', 
     source: [1, 2, 3, 4] }, {}, ], 
     contextMenu: true, 
     width: '100%',
    height: 'auto', 
    colWidths: [480, 480, 120, 120, 120, 120, 480], 
    rowHeights:[40, 40, 40, 40, 40, 40, 40], 
    manualColumnResize: true, 
    licenseKey:'non-commercial-and-evaluation', });

{# --- Bouton de sauvegarde --- #}
Handsontable.dom.addEvent(save, 'click', () => {
  // save all cell's data
  ajax('/docs/11.1/scripts/json/save.json', 'POST', JSON.stringify({ data: hot.getData() }), res => {
    const response = JSON.parse(res.response);

    if (response.result === 'ok') {
      save.innerText = 'Données sauvegardées';
    } else {
      save.innerText = 'erreur de sauvegarde';
    }
   });
});
  
  </script>

part of my controller

/**
     * @Route("/TravailEquipe", name="TravailEquipe")
     */
    public function TravailEquipe(): Response
    {
        return $this->render('pedagogie/TravailEquipe.html.twig', [
            'controller_name' => 'PedagogieController',
        ]);
    }

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda