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

130
Views
Show data from back using python with ajax in datatable

I got a problem when I want to show Datatable. I'm using python to return data

return jsonify({'data': {'1': list_data, '2':list_data2}})

Then I have datatable :

tableUtama = $('#tableUtama').DataTable({
    'scrollY': '250px',
    'scrollX': true,
    'searching': false,
    'ordering': false,
    'info': false,
    'paging': false,
    'autoWidth': true,
    "ajax": {
      "url": "/processData",
      "dataType": "json",
      "dataSrc": function (data) {
          return data.data['1']
        }
        "columnDefs": [
        { 'targets': 0, "data": "kd_toko" },
        { 'targets': 1, "data": "name_toko"},
        { 'targets': 2, "data": "loc_toko" },
        { 'targets': 3, "data": "type_toko" },
        { 'targets': 4, "data": "dates" }]
         }
         })

All data inside data.data['1'] not showing. but only show row here's result

please help me

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I solved my problem, it's because I put the columnDefs in wrong place. I should close ajax first using parentheses and then add columnDefs

tableUtama = $('#tableUtama').DataTable({
'scrollY': '250px',
'scrollX': true,
'searching': false,
'ordering': false,
'info': false,
'paging': false,
'autoWidth': true,
"ajax": {
  "url": "/processData",
  "dataType": "json",
  "dataSrc": function (data) {
      return data.data['1']
    }
    },
    "columnDefs": [
    { 'targets': 0, "data": "kd_toko" },
    { 'targets': 1, "data": "name_toko"},
    { 'targets': 2, "data": "loc_toko" },
    { 'targets': 3, "data": "type_toko" },
    { 'targets': 4, "data": "dates" }
      ]
     
     })
about 4 years ago · Juan Pablo Isaza Report
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!