Using two tables divided data value

Using two tables divided data value

eri545eri545 Posts: 1Questions: 1Answers: 0
edited October 2021 in Free community support

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Hello. I'm using two tables with same settings using ajax to get same data source. I'm trying to divide tables depending by json value. I.E
if ( value = "iOS") show this row in the first table
if ( value = "Android") show this row in the second table

here my example json data

{"data":[
{"id":"001",
"type":"buy",
"time":"2021-10-07T15:45:43.087Z",
"status":"done",
"amount":"300.00",
"os":"Android",
},

{"id":"002",
"type":"buy",
"time":"2021-10-06T20:15:09.633Z",
"status":"partially",
"amount":"20.00",
"os":"iOS",
},
{"id":"003",
"type":"buy",
"time":"2021-10-07T15:45:43.087Z",
"status":"done",
"amount":"10.00",
"os":"iOS",
},

Table script

var tables = $('table.display').DataTable( {
        "lengthMenu": [ [15, 25, 50, 75, -1],[15, 25, 50, 75, "All"] ],
        "order": [[ 1, "desc" ]],
        "ajax": {
            "url": "dataurl.php",
            "type": "GET",
            "data": {
                "url": window.location.href
            }
        },
        "rowId": function(a){return 'rowid_'+a.id;},
        "columns": [
            {
                "className":      'dt-control',
                "orderable":      false,
                "data":           null,
                "defaultContent": ''
            },
            { "data": "time" },
            { "data": "type" },
            { "data": "status" },
            { "data": "amount" },
            { "data": "os" } ],
    });

Is there a method to filter the data that i receive from json ajax and to send them to the wanted table?

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    You could use ajax.dataSrc - see the last example on that page, it's manipulating the data returned by the server,

    Colin

Sign In or Register to comment.