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

196
Views
add or remove column from db where datatables library is used in codecanyon codeigniter script

I am getting error in js when I am adding or removing column in controller. As I am getting data in Network, its mean bug is in js code.

Error

enabled:795 Uncaught TypeError: Cannot read properties of undefined (reading 'split') at jquery.dataTables.min.js:18

JS CODE

  $(document).ready(function () {
    var oTable = $('#dynamic-table').dataTable({
        "aaSorting": [[3, "asc"]],
        "aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
        "iDisplayLength": <?=$settings->rows_per_page;?>,
        'bProcessing': true, 'bServerSide': true,
        'sAjaxSource': '<?php echo base_url(); ?>panel/customers/getAllCustomers/<?php echo $toggle_type;?>',
        'fnServerData': function (sSource, aoData, fnCallback) {
            aoData.push({
                "name": "<?php echo $this->security->get_csrf_token_name() ?>",
                "value": "<?php echo $this->security->get_csrf_hash() ?>"
            });
            $.ajax({'dataType': 'json', 'type': 'POST', 'url': sSource, 'data': aoData, 'success': fnCallback});
        }, 
        "aoColumns": [
        null,
        null,
        null,
        null,
        {mRender: tp},
        {mRender: actions},
                
        ],
       
    });
          
});

Controller:

    public function getAllCustomers($type = NULL)
     {
     $this->load->library('datatables');
     $this->datatables
        // ->where('id !=', 1)
        ->select('id, CONCAT(first_name, " ", last_name ) as name, company, address, email, 
     telephone, disable')
        ->from('clients');
    // if ($type === 'disabled') {
    //     $this->datatables->where('disable', 1);
    // } elseif($type === 'enabled') {
        $this->datatables->where('disable', 0);
    // }
    $this->datatables->where('(universal=1 OR store_id='.$this->activeStore.')', NUll, FALSE);

    $this->datatables->add_column('actions', "$1___$2", 'id, disable');
    $this->datatables->unset_column('id');
    $this->datatables->unset_column('disable');
    echo $this->datatables->generate();
   }
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!