Use datatables to retrieve data but no rendering?

Use datatables to retrieve data but no rendering?

loukinglouking Posts: 259Questions: 52Answers: 0

I think this might be a bit of a strange question, but...

I need to gather data from my server to display a chart. I plan to use d3js for the chart display and don't plan to render the table for this data.

Since I also can display this as a table on another view, I already have a server endpoint which could return the data I'm looking for, but the endpoint expects the request to be from datatables.

Is there a way to set up datatables so that I can send the request, with appropriate filters, and catch the ajax response to supply to d3, without rendering a table?

I know I can just create another endpoint on the server tailored for what d3 expects. I'm just weighing my options.

This question has accepted answers - jump to:

Answers

  • loukinglouking Posts: 259Questions: 52Answers: 0

    Oh! I bet I can just use the dom option to control this, right?

  • ewmantheiewmanthei Posts: 14Questions: 1Answers: 2
    Answer ✓

    You could do this with the dom. Also, you could simply write an ajax request and not mess with datatables altogether. JQuery is useful for you, but I'm not sure why you need datatables if you aren't using the GUI. I may be misunderstanding though.

  • loukinglouking Posts: 259Questions: 52Answers: 0
    edited July 2016

    Thanks for your response.

    The use case is to reuse yadcf for some filtering of the data to be shown in the chart. yadcf requires datatables for this. By doing this I also get the benefit of reusing the server side code I have in place to show the data in a table.

    On the server side I'm using sqlalchemy-datatables which, coupled with yadcf, handles all the filtering for me, but expects a (rather complex) datatables URL query.

  • ewmantheiewmanthei Posts: 14Questions: 1Answers: 2

    Best of luck!

  • loukinglouking Posts: 259Questions: 52Answers: 0

    In the unlikely event others come looking for this...

    It looks like the t (Table) element cannot be turned off with the dom option. So I set my dom option as

    dom: '<"dt-hide"t>'

    and used

    .dt-hide {
        visibility: hidden;
    }
    
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    This is correct - at a minimum the dom option must have the t character in it. Otherwise the DataTable won't be displayed at all and DataTables is somewhat pointless :smile:. A hidden table is perhaps the best way to go if you want DataTables to source the data for you but you don't want the table).

    Allan

This discussion has been closed.