Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

250
Visualizações
Pre-Filter jQuery DataTables AJAX result based on specific column value

I have a JSON file containing all the data, so basically it's the data for 10 different tables in one file. Now, when I'm on a certain page (A) I only wish to output the data from the file where the value of column[0] (my identifier sits in the first column) is "A".

I'm really not sure what to put where:

$('#example').DataTable( {
    "ajax": '../ajax/data/arrays.txt'
} );

Any ideas? Thanks!

Got it working.

$('#example').dataTable( {
    "ajax": {
        "url": "../ajax/data/arrays.txt",
        "dataSrc": function(json) {
            let data = json.data;
            let filter = data.filter(function(value, index, arr){
                return value[0] === 'A';
            });
            return filter;
        }
    }
} );
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You can use the dataSrc option of the ajax configuration:

 $('#example').DataTable( { "ajax": { url: '../ajax/data/arrays.txt', dataSrc: function(json) { // run logic on json to select only your desired rows return result; } });
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda