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

[eluser]johnwbaxter[/eluser]
Wow, that's the strangest thing. I haven't changed a thing and now it's working. That's very very odd.

Thanks for the response though!

[eluser]LoganPHP[/eluser]
My server code is
Code:
$this->datatables
            ->select("tps.id,tp1.image,tps.title,IF(tps.status=1,'E','D') as st,tps.views",FALSE)
            ->from('tb_photos AS tps')
            ->join('(SELECT tp.photos_id, MAX( tp.id ) AS lastid FROM tb_photo AS tp GROUP BY tp.photos_id) AS lastphoto', 'tps.id = lastphoto.photos_id','left')
            ->join('tb_photo as tp1', 'lastphoto.lastid=tp1.id','left')
            ->edit_column('tp1.image', 'thumb)link', 'tp1.image')
            ->add_column('comments', 'comment link', 'tb_videos.id')
            ->add_column('action', 'action_link', 'tb_videos.id');

my client side code is

Code:
'bProcessing'    : false,
                      'bServerSide'    : true,
                      'bAutoWidth'     : false,
                      'sAjaxSource'    : '<?php echo site_url('backend/photos/listener');?>',
                      'aoColumns' : [
                            { 'sName': 'tps.id','bVisible': false},
                            { 'sName': 'tp1.image',"bSearchable": false},
                            { 'sName': 'tps.title'},
                            { 'sName': 'st',"bSearchable": false},
                            { 'sName': 'tps.views',"bSearchable": false},
                            { 'sName': 'comments',"bSearchable": false},
                            { 'sName': 'action',"bSearchable": false}
                        ],
                       'fnServerData': function(sSource, aoData, fnCallback)
                      {
                        $.ajax
                        ({
                          'dataType': 'json',
                          'type'    : 'POST',
                          'url'     : sSource,
                          'data'    : aoData,
                          'success' : fnCallback
                        });
                      },
                        sDom: '<"block-controls"<"controls-buttons"p>>rti<"block-footer clearfix"lf>',
                        fnDrawCallback: function()
                        {
                            this.parent().applyTemplateSetup();
                        },
                        fnInitComplete: function()
                        {
                            this.parent().applyTemplateSetup();
                        }

My problem is here IF(tps.status=1,'E','D') as st.

If i use AS in main SELECT query it doesn't output properly.

Whenever i use AS,I'm facing this problem.How can i solve this problem?

Thanks in advance,
Logan

[eluser]ηυмвєяσηє[/eluser]
Hey,

The library supports basic sql queries atm. Never tried subqueries with it before.

I've made some changes (0.5.2beta):
- fixed select method, it'll select queries like "IF(tps.status=1,‘E’,‘D’) as st" properly.
- changed callback parameter style, in order to use comma insted of '|'.
for example : callback_substr(email,0,4)
- unset_column($column) method has been added.
- *fixed an issue on filtering. (when using 'as' in select method, sql was giving error.)

Lib: http://bit.ly/l4HKzG

What do you think ?

couldnt test it very well, i hope you do.

Regards,
Yusuf

[*Updated: 15.06.2011]

[eluser]LoganPHP[/eluser]
Our library supports sub-queries very well.

Still now i have problem with ....IF(tps.status=1,‘E’,‘D’) as st.... main select query.

json return properly,only output collapsed.

How can i solve this?

[eluser]ηυмвєяσηє[/eluser]
ive tried "IF(tps.status=1,‘E’,‘D’) as st " seems no problem, its working.

can you show me the output or any error ? And did you change anything on server side or its still same ?

[eluser]LoganPHP[/eluser]
I have not changed anything.

My output collapsed like attached image.

usually AS is working well,only 'if' clause AS is now my problem.

Note it But my json output comes properly.

[eluser]ηυмвєяσηє[/eluser]
i couldnt see any wrong things with if clause.. all i can see is undefined columns.

[eluser]Unknown[/eluser]
thanks for the great job.

[eluser]umefarooq[/eluser]
really great library i have one question how can i use php functions with in library to perform a specific task like i want to replace - from one of the column record like

Code:
str_replace("-"," ",$column_name)

[eluser]ηυмвєяσηє[/eluser]
you can use php functions with callback_functionname(param1,param2, ..) (download latest #162 ) :

Code:
->edit_column('column_name', '$1', 'callback_str_replace(-, ,column_name)')




Theme © iAndrew 2016 - Forum software by © MyBB