Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

235
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!