Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

236
Vistas
Create Datatable columns according to if condition

Below I attached my table. enter image description here I want to create a datatable with two columns price and schedule_from if TYPE=='retail'. this is my code.

 $('#retail-price-history').DataTable({
   data: record.retail_history,  
   destroy: true,
   searching: false,
   ordering: false,
   dom: '<<"row"<"col">>t<"row"<"col">>>',
   columns: [     
     {
         data: "price",
      "render": function ( data, type, full, meta ) {
         return data/100;
      }
      },
      { data: "scheduled_from"
      
      
      }]


});

This is my json record.retail_history

{[
    
    TYPE: "retail"
    id: 6069714
    price: 899
    scheduled_from: "2022-01-20"
    sku: 1435530
]
    [
    TYPE: "cost"
    id: 123
    price: 599
    scheduled_from: "2022-11-01"
    sku: 1435530
]}

how to populate data on my data table if the condition satisfy TYPE =='retail'. Now According to my code its populating all data either TYPE is 'retail' or 'cost'

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda