Partial load the data to create table

Partial load the data to create table

gzboy007gzboy007 Posts: 3Questions: 1Answers: 0

Hi mates,

I'm using below to create table

    table_2 = $('#TargetCompanyCounterParty').DataTable( {
        "ajax": {
            "url": "./Python/Output/Nodes/Level_3/" + vTargetCompany + ".json",
            "dataSrc": ""
        },
        "columns": [
            { "data": "id" },
            { "data": "type" },
            { "data": "gender" }
        ],
        "lengthMenu": [[5, 25, 50, -1], [5, 25, 50, "All"]],
        "pageLength": 5,
        columnDefs: [
            { width: 330, targets: 0 }
        ],
        fixedColumns: true  
    } );

How can I load the subset of this data? For example let's say gender == 'Male'. I try to search it in forum however it's no luck.

Thanks in advance!

Answers

  • gzboy007gzboy007 Posts: 3Questions: 1Answers: 0

    We can use this approach, however it's global search. And I don't want it to show in search box.

    "search": {
    "search": "Male"
    }

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947

    You can use ajax.data to send a search term to the server via the ajax request. This will allow you to return just the data of interest.

    We can use this approach, however it's global search. And I don't want it to show in search box.

    You can hide the global search input using the dom option. If you want a global search input you can create your own and create an event handler to use search() to search for the input.

    Kevin

  • gzboy007gzboy007 Posts: 3Questions: 1Answers: 0

    Thanks kthorngren. Learnt a lot!~

    Finally I solved it using this approach, it searchs the column without text in search box.

    "searchCols": [
    null,
    null,
    { "search": "WWM" },
    null
    ]

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947

    There is that option too :smile:

    Kevin

This discussion has been closed.