Topic: updating editable datatable from database failed

atinbop free asked 5 years ago


Does somebody have the JS and C# code to load Editable table and to save data in the database? please i need help i have try to pass json serialise data from the server to to the JS to update the JS variable named dataset in Bubble Editor template. But its not working.


Aliaksandr Andrasiuk staff answered 5 years ago


Hi,

Can you show the code you are using for the changing dataset variable?

After successfully received data from the server it's enough to update the body of your table, f.e:

        //Basic setup
        $('#dtBasicExample').DataTable();
        $('.dataTables_length').addClass('bs-select');
        //

       // saving your datatable to the variable
        let dataTable = $('#dtBasicExample');
        //saving datatable's body to the variable
        let dataTableBody = dataTable[0].childNodes[3];

        //After receiving data from the server 
        //you should process the data to the similar look 
        let updatedBody = `<tr>
          <td>Tiger Nixon</td>
          <td>System Architect</td>
          <td>Edinburgh</td>
          <td>61</td>
          <td>2011/04/25</td>
          <td>$320,800</td>
        </tr>
        <tr>
          <td>Garrett Winters</td>
          <td>Accountant</td>
          <td>Tokyo</td>
          <td>63</td>
          <td>2011/07/25</td>
          <td>$170,750</td>
        </tr>`;

         //sets the received and processed data as a body 
        const setNewBody = body => (dataTableBody.innerHTML = body);

        //
        fetch('...')
          .then(response => response.json())
          .then(() => setNewBody(updatedBody));

         //the code above should be replaced with:
         //then(data => processData(data))
         //then(res => setNewBody(res))

      });

Hope I could help.

Best regards.



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.8.5
  • Device: PC
  • Browser: Opera
  • OS: Windows
  • Provided sample code: No
  • Provided link: No