How to use server side processing in electron ?

How to use server side processing in electron ?

aimen kaaaimen kaa Posts: 2Questions: 1Answers: 0

I'm trying to work out how to implement the server side processing on electron, i'm getting my data directly from sqlite3 file (with knex) without any rest request, is there any way to override how datatable get the data, from getting it with ajax rest request to a custom funtion that returns it as json or whatever format works.
thank you.

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Possibly your best bet is to use our NodeJS libraries for Editor. They support server-side processing (they also use Knex). This is the installation page. You don't need an Editor license just to use the server-side libraries.

    Allan

  • aimen kaaaimen kaa Posts: 2Questions: 1Answers: 0

    Hello there @allan ,
    i only found 'editor for server side ... etc'
    i dont think you understood my question, here's an example:
    lets say in my electron project i have 'products.js' (lets call it a node module) where there is an async function getData(......) which gets the data from my sqlite3 db,
    i want to display this data in this datatable and be able to use live search and pagination ...etc :

    dataTable = $('#listprods').DataTable({
    dom : 'Bfrtip', "deferRender": true, "order": [[ 0, "desc" ]],
    "processing": true,
    "serverSide": true,
    'ajax': ???????????

    buttons: [ 'excelHtml5', 'csvHtml5'],
    'iDisplayLength': 25,
    "language": {
        "lengthMenu": "Display _MENU_ Records Per Page",
        "info": "Showing Page _PAGE_ / _PAGES_ of _TOTAL_ entries",
    },
    

    });

    now in a normal client/server case you'd put a post api url for ajax, right?.
    the question is : in my case what do i do?, i dont have an api or a server i only have an async function or an sqlite file.

    thank you for your time;

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Thanks for the clarification. I've not written Electron apps myself, so I don't know how you define an endpoint in it, but a quick Google lead me to this documentation, so the ajax option in DataTables would just point to the endpoint you define - e.g. ajax: '/api/users' (or whatever). As long as it responds with JSON, then DataTables will be able to consume it.

    Note that your serverSide option complicates things since then the server-side (Electron's end point in this case) has to do all the filtering, ordering, etc. Only enable that option if you have tens of thousands or more rows to display in the table.

    Allan

Sign In or Register to comment.