Welcome Guest, Not a member yet? Register   Sign In
Ignited DataTables
#91

[eluser]ηυмвєяσηє[/eluser]
dobbler, i have updated the library. it should work now. download it again.


edit: we have also updated wiki.
#92

[eluser]Chauzu[/eluser]
Hi, this is an awesome job, just wondering if it's possible to pass parameters to the custom filters from the view. I'm checking the Datatable's multifilter plugin without luck.
#93

[eluser]dobbler[/eluser]
Thanks for your quick response ηυмвєяσηє!
#94

[eluser]Chauzu[/eluser]
Answering to myself, it is possible to send parameters from the view to the custom filters, just need to match the 'sName' Datatable property to the column's name and use the Multifilter plugin.

Again, thanks for this awesome work.
#95

[eluser]Mario Ropič[/eluser]
Hello!

I am using dataTables with Codeigniter 2 and I have problems with server-side datas..

I have attached screens to this post with two errors..


This is my controller code:

Code:
function datatables()
    {
        $table = 'products';
        $columns = array('products_id', 'products_price');
        $index = 'products_id';

        // Join Definition: join group name from the user groups table where the user group table's id matches the table user's id
        $joins = array();
        $joins['products_description']['columns'] = array('products_name');
        $joins['products_description']['fk'] = 'products.products_id = products_description.products_id';
        $options['joins'] = $joins;

        // Custom Column Definition: add an "Edit" and a "Delete" column
        $custom_columns['edit']   = array('Edit', array('products.products_id'));
        $custom_columns['delete'] = array('Delete', array('products.products_id'));
        $options['custom_columns'] = $custom_columns;

        // Custom Filter Definition: only show users who belong to the Admin group
        //$options['custom_filter'] = 'user_groups.group_name = "Admin"';

        $data['result'] = $this->datatables->generate($table, $columns, $index, $options);
        $this->load->view('ajax', $data);
        
    }


This is my JavaScript code:

Code:
$('#example').dataTable({
      'bProcessing'    : true,
      'bServerSide'    : true,
      'sAjaxSource'    : 'server/datatables',
      'sPaginationType': 'full_numbers',
      'bAutoWidth'     : false,
      'aoColumns'      : [
        { 'sName': 'edit', 'bSortable': false },
        { 'sName': 'delete', 'bSortable': false },
        { 'sName': 'products.products_id', 'bVisible': false },
        { 'sName': 'products.products_price' }
      ],
      'fnServerData'   : function(sSource, aoData, fnCallback)
      {
        $.ajax({
          'dataType': 'json',
          'type'    : 'POST',
          'url'     : sSource,
          'data'    : aoData,
          'success' : fnCallback
        });
      },
});


What am I doing wrong?

Regards, Mario
#96

[eluser]ηυмвєяσηє[/eluser]
well,
first u've called 5 columns from controller (2from table,1 from joins, 2 from customs).

Code:
'aoColumns'      : [
        { 'sName': 'edit', 'bSortable': false },
        { 'sName': 'delete', 'bSortable': false },
        { 'sName': 'products.products_id', 'bVisible': false },
        { 'sName': 'products_description.products_name' },
        { 'sName': 'products.products_price' }
      ],

and if u don't use the id value in custom columns, u can do this simply.
Code:
$custom_columns['edit']   = array('Edit');
if u do, you should put a $1 so it can replace.
Code:
$custom_columns['edit']   = array('Edit $1', array('products.products_id'));

plus, be sure the path is right,
Code:
'sAjaxSource'    : <?php echo base_url(); ?>'server/datatables',

edit : and u need a file that called ajax.php in view folder.
Code:
$this->load->view('ajax', $data);
and ajax.php will be like;
Code:
<?php echo $result ?>

these are things i have noticed at first look. IF these doesnt work, Click [+] on POST, and copy the error here.

Regards,
Yusuf
#97

[eluser]cLin[/eluser]
I have a question custom columns...would i be able to run operations in it? Currently, I have a variable like
Code:
$custom_columns['ctr'] = array('$1/$2', array('sq_rows_cleaned.clicks', 'sq_rows_cleaned.impressions'));
which displays as #/$2 (the $1 being replaced but the $2 isn't replaced.

Also, how would I be able to run statements in there? For example, sometimes $2 (impressions) would appear as zero and if it tries to run any number divided by zero, it'll show up as an error. Before I had a statement like

Code:
if($impression == 0) { $ctr = ""; } else { $ctr = number_format($clicks/$impressions, 2, '.', '')*100; }

Would I be able to do something like that in my listener before it outputs the results?

Thanks in advance for any help
#98

[eluser]ηυмвєяσηє[/eluser]
hmm.. you didnt add "sq_rows_cleaned.impressions" as a column neither $columns and $join, did you ?

"impressions" column should be selected. After that, it shouldnt give errors.

and about running operations; i prefer to do that at js part. use fnRender pref.
and eval("50/20") will return the value as an example.

lets say its 5th column in the table.

{ "sName": "ctr", "fnRender": function (oObj){return eval(oObj.aData[4]);} },

Regards
Yusuf
#99

[eluser]Mario Ropič[/eluser]
Quote:ηυмвєяσηє

Thank you for your reply.

I get now another error:

Code:
invalid label
[Prekini ob tej napaki] {"sEcho":1,"iTotalRecords":"1377","iTo...SB 800DPI ČRNA\/SREB 22859","Edit

POST answer:
Code:
{"sEcho":1,"iTotalRecords":"1377","iTotalDisplayRecords":"1377","aaData":[["7925","11.6700","VI MIŠ OPTIČNA IZVLEČNA ČRNA 0,75 m 23241","Edit","Delete"],["7924","4.6700","VI MIŠ OPTIČNA USB 800DPI ČRNA\/SREB 22859","Edit","Delete"],["8454","81.3700","RTC SESALEC VELIKI+MALI BSC2300 1021003","Edit","Delete"],["7926","13.7000","EDN MIŠKA NOTEBOOK LASER USB 81094","Edit","Delete"],["7927","14.2500","EDN MIŠKA ZA NOTEBOOK OPTICAL 81035","Edit","Delete"],["8457","50.1800","RTC WELLNESS SET WLS 100 1029002","Edit","Delete"],["8455","31.1200","RTC STOJEČI MEŠALNIK S POSODO HMS 300 1014002","Edit","Delete"],["8456","27.5000","RTC STROJ ZA SENDVIČE ALULINE V3 IN 1 1023003","Edit","Delete"],["8010","1.4400","VI PODLOGA ZA MIŠ FABRIK 3 COLORS 21429","Edit","Delete"],["7879","41.6600","RAZER MIŠ DIAM.3G 1800 FROST BLUE","Edit","Delete"]],"sColumns":"products.products_id,products.products_price,products_description.products_name,edit,delete"}

Thank you!

[eluser]ηυмвєяσηє[/eluser]
Invalid label error is usually caused by validation.js, if u have that update it.




Theme © iAndrew 2016 - Forum software by © MyBB