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

[eluser]Mario Ropič[/eluser]
[quote author="ηυмвєяσηє" date="1302963039"]Invalid label error is usually caused by validation.js, if u have that update it.[/quote]

It works! You are amazing Smile

Thank you and have a nice day! Regards from Slovenia

[eluser]cLin[/eluser]
[quote author="ηυмвєяσηє" date="1302961131"]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[/quote]

This is how my code looks like for the controller

Code:
$table = 'sq_rows_cleaned';  
        $index = 'search_term';
        $columns = array('search_term', 'length', 'seen', 'impressions', 'clicks', 'costs');
        $custom_columns['ctr'] = array('$1 $2', array('sq_rows_cleaned.clicks', 'sq_rows_cleaned.impressions'));
        $options['custom_columns'] = $custom_columns;    
        $options['custom_filter'] = "sq_rows_cleaned.reports_id = 1";
        $data['result'] = $this->datatables->generate($table, $columns, $index, $options);

would it be sq_rows_cleaned.impressions or just impressions? I figure since the custom_filter works, it would be sq_rows_cleaned.impressions. Also, is there a way to hide the sNames of the custom_column so it's not the sql table names? Seems like a exposing my database.

Thanks,
Chris

[eluser]ηυмвєяσηє[/eluser]
hey Chris
your code was right. The problem was in the library =). I dont know when it happened but replace function was bugged.

edit : i made a 2nd fix. redownload the library please. sorry about that ^^

[eluser]cLin[/eluser]
[quote author="ηυмвєяσηє" date="1302988323"]hey Chris
your code was right. The problem was in the library =). I dont know when it happened but replace function was bugged.

edit : i made a 2nd fix. redownload the library please. sorry about that ^^[/quote]

Awesome! So, for this
Code:
{ “sName”: “ctr”, “fnRender”: function (oObj){return eval(oObj.aData[4]);} },

would aData[4] be whatever is outputted from $custom_columns['ctr']? Just trying to figure out where to run my if statement, either on the javascript side or the controller side. I'm still confused as to where I would setup this to run

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


I'm not really familiar with replace so I don't think doing something like the below would work.

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



Thanks for helping me.

[eluser]ηυмвєяσηє[/eluser]
check here
http://jsfiddle.net/Fgx2u/4/
u can handle it with some easy javascript codes.


well u can do something like this;

Code:
{ “sName”: “ctr”, “fnRender”: function (oObj){return (oObj.aData[4].replace(/[0-9]+\//gi,'') == 0) ? 0 : eval(oObj.aData[4]).toFixed(2);} },

[eluser]cLin[/eluser]
[quote author="ηυмвєяσηє" date="1303042018"]check here
http://jsfiddle.net/Fgx2u/4/
u can handle it with some easy javascript codes.


well u can do something like this;

Code:
{ “sName”: “ctr”, “fnRender”: function (oObj){return (oObj.aData[4].replace(/[0-9]+\//gi,'') == 0) ? 0 : eval(oObj.aData[4]).toFixed(2);} },
[/quote]

Thanks, I went about a different way but your method is cleaner. Is there a way to do this on the controller end or is that a limitation of using ajax and datatables? I can't seem to sort by the custom column rows even when just display a single variable (like just showing the costs column, clicking on the column header won't sort it at all). All it does is, it'll show processing, the data will be retrieved but nothing will be sorted.

[eluser]cryogenix[/eluser]
@yusuf: cleaned the code a bit. the last push had some mismatched braces so i tinkered with it a little. did some testings and it seems fine. please test it as well and lemme know Wink

[eluser]cLin[/eluser]
[quote author="ηυмвєяσηє" date="1303042018"]check here
http://jsfiddle.net/Fgx2u/4/
u can handle it with some easy javascript codes.


well u can do something like this;

Code:
{ “sName”: “ctr”, “fnRender”: function (oObj){return (oObj.aData[4].replace(/[0-9]+\//gi,'') == 0) ? 0 : eval(oObj.aData[4]).toFixed(2);} },
[/quote]

I have one last question, it seems like sorting is messed up for rows using custom columns, are you able to sort custom columns?

[eluser]cryogenix[/eluser]
well we usually only use custom columns for action buttons like edit or delete so they don't actually need to be sortable. unless you can give me an example of why your custom columns need to be sortable?

[eluser]ηυмвєяσηє[/eluser]
DataTables 1.8 beta 1 released
i have tested and it seems the library still works.

Please let us know if you have any trouble.

Regards,
Yusuf




Theme © iAndrew 2016 - Forum software by © MyBB