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

163
Visualizações
Yajra/Jquery datatable how to exclude records based on condition

How can I exclude data based on my condition on the addColumn function?

What I tried is this but it will include records that are > 0

    ->addColumn('total', function ($row) {
        $arr = array(abs($row->fba_fee_count),abs($row->referral_fee_count));
        if($arr > 0) {
            return array_sum($arr);
        }

On the frontend side, I also tried

    "createdRow": function( row, data, dataIndex ) {
        if ( data.total === 0 ) {
            $(row).hide();
        }
    },

Now it hides the data but the pagination is showing for all the data. As you can see in the image below. I got 3 records but the pagination is for all the records.

enter image description here

Anyone can help? Thanks in advance.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I think better you can restrict in query if sum of total is greater than zero .

$result= ModelName::havingRaw('(referral_fee_count+fba_fee_count)>0')->get();

or

$result=ModelName::having(DB::raw('referral_fee_count+fba_fee_count'),'>',0)->get();

Also for yajra datatable no need to use get() .

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