• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

133
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'

almost 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error