Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81986

How can add custom column in array

$
0
0

Hello, I have string which want to delimiter with row and columns, also add custom column for checkbox functions:

Oleg\tGagarin\tMoscow\tCEO\r\nMax\tStanislavov\tPiter\tSEO\r\nMasha\tDarova\tLondon\tCFO\r\nAlex\tKukushkin\tBerlin\tCoder\r\n
Where \r\n is is delimiter for row
Where \t is is delimiter for columns

My output is

[data] => Array
(
    [0] => Array
        (
            [0] => Sasha
            [1] => Kukushkin
            [2] => Moscow
            [3] => CEO
        )

    [1] => Array
        (
            [0] => Oleg
            [1] => Gazmanov
            [2] => Piter
            [3] => SEO
        )

    [2] => Array
        (
            [0] => Masha
            [1] => Darina
            [2] => London
            [3] => Sales
        )
)

It's work well, but I add checkboxes function
https://www.gyrocode.com/projects/jquery-datatables-checkboxes/

Where checkox is first column, next I must add in my array [id] = > {key}

$data_decode_row = explode('\r\n', $data['users_result']);
$data_explode_colm = array();

foreach($data_decode_row as $d_k => $d_v){
    $data_explode_colm[$d_k] = explode('\t', $d_v);
    $result = array();
    foreach($data_explode_colm as $e_k => $e_v){
          $result['data'][$e_k]['id'] = $e_k;
          $result['data'][$e_k] = $e_v;
    }
}

But print_r is not shoe me ['id']

Any ideas?

var table_type = $(this).data('table');
var group_id = $(this).data('id');

// DataTable
var table = $('.UsersResultTable.'+table_type+'').DataTable({
  retrieve: true,
  ajax: {
    url: "/ajax/GetUsers",
    type: "POST",
    data : {
        group_id : group_id
    },
  },
  deferRender: true,
  sDom: 'rtlfip',
  // bFilter: false,
  columnDefs: [
     {
        compact: true,
        targets: 0,
        checkboxes: {
           selectRow: true
        }
     }
  ],
  select: {
     style: 'multi'
  },
  order: [[1, 'asc']]
});

Thanks.


Viewing all articles
Browse latest Browse all 81986

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>