Is it possible to not load specific json data into a table if a cell is equal to a certain value?

Is it possible to not load specific json data into a table if a cell is equal to a certain value?

Kay93Kay93 Posts: 1Questions: 1Answers: 0

Hello, I was just wondering if it was possible to not load specific json data into a table if a cell is equal to a certain value. I have tried using the rowCallback method to "hide" the data, but I do not like this solution because the data is still loading in the back end. I would rather prefer to not load the unused data at all.

Below is an example of what I used to just "hide" the data for now.

 "rowCallback": function( row, data, index ) {
          if (data.team_code == "TORONTO") {
            $('td', row).css('background-color', '#ccc');
          }
          else {
              $('td', row).addClass('hide');
          }             
       },

Any answers would be very much appreciated.

Answers

  • kthorngrenkthorngren Posts: 21,301Questions: 26Answers: 4,946

    I think the best option is to have the server code retrieve only the data desired by filtering the query and returning only the desired data. If you are unable to do this then you could use the ajax.dataSrc function option to remove the unwanted data before Datatables processes it. The docs have an example of using a function.

    Kevin

This discussion has been closed.