ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Ignited DataTables

July 15, 2010 2:51am

Subscribe [119]
  • #226 / Aug 31, 2011 1:43am

    cryogenix

    90 posts

    issue fixed. tank you for your feedback

  • #227 / Aug 31, 2011 2:24am

    hyperfire

    53 posts

    Got it.
    If you use CI CSRF protection, add something like this to your jQuery:

    'fnServerData': function(sSource, aoData, fnCallback){
                aoData.push( { "name": "ci_csrf_token", "value": "<?php echo $this->security->get_csrf_hash() ?>" } );
                $.ajax({
                    'dataType': 'json',
                    'type': 'POST',
                    'url': sSource,
                    'data': aoData,
                    'success': fnCallback
                });
            }

    And everything will work as expected.

  • #228 / Sep 02, 2011 1:05am

    smatakajr

    40 posts

    Hi

    Im having some issues here and Im hoping you can help.

    Im trying to add custom columns data without having the columns
    duplicated.

    $this->datatables
                ->select('clickbank_id,Title,Description')
                ->from('clickbank')
                ->add_column('clickbank_id', '<a href="#">$1</a>','clickbank_id')    
                ->add_column('Title', '<a href="#">$1</a>','Title')    
                ->add_column('Description', '<a href="#">$1</a>','Description');        
                echo $this->datatables->generate('UTF-8');


    The problem is it wants to do 6 columns when infact I only want the 3 custom
    columns.

    I have been hacking at the code for hours now..with no success. It seems
    the ROW keys are so embedded in pattern matching and array diff that
    i cant dynamically unset the same columns

    Maybee someone has a work around here I can mess with?

    Thanks
    Ricky


    ===== UPDATE =======

    Wow im an idiot ... lol 4 hours wasted 1 line of code dOAH!!!

    foreach($this->add_columns as $field => $val)
                {
                  //unset orginal column
                  $this->unset_column($field); /// <--- Why Didnt I think of this Earlier!!!
                  if($this->check_mDataprop()){
                    $aaData[$row_key][$field] = $this->exec_replace($val, $aaData[$row_key]);
                  }else{
                    $aaData[$row_key][] = $this->exec_replace($val, $aaData[$row_key]);
                  }
                }

     

    Ricky

  • #229 / Sep 03, 2011 3:50am

    ηυмвєяσηє

    109 posts

    This isnt a good solution.

    foreach($this->add_columns as $field => $val)
                {
                  //unset orginal column
                  $this->unset_column($field); /// <--- Why Didnt I think of this Earlier!!!
                  if($this->check_mDataprop()){
                    $aaData[$row_key][$field] = $this->exec_replace($val, $aaData[$row_key]);
                  }else{
                    $aaData[$row_key][] = $this->exec_replace($val, $aaData[$row_key]);
                  }
                }

    You can use unset_column in your controller.

    $this->datatables
                ->select('clickbank_id,Title,Description')
                ->from('clickbank')
                ->add_column('clickbank_id', '<a href="#">$1</a>','clickbank_id')    
                ->add_column('Title', '<a href="#">$1</a>','Title')    
                ->add_column('Description', '<a href="#">$1</a>','Description')
                ->unset_column('column_name')->unset_column('column2_name');        
                echo $this->datatables->generate('UTF-8');

    or.. dont add another column. use edit_column.

    $this->datatables
                ->select('clickbank_id,Title,Description')
                ->from('clickbank')
                ->edit_column('clickbank_id', '<a href="#">$1</a>','clickbank_id')    
                ->edit_column('Title', '<a href="#">$1</a>','Title')    
                ->edit_column('Description', '<a href="#">$1</a>','Description');        
                echo $this->datatables->generate('UTF-8');
  • #230 / Sep 04, 2011 10:51pm

    cryogenix

    90 posts

    @yusuf: i noticed the wiki page on github have no usage details for the method unset_column. might as well edit it? ^_^

  • #231 / Sep 10, 2011 9:37pm

    nosuchnick

    3 posts

    Hello. I’ve been using datatables but never used the server side options. Now I want to use it in a codeigniter project and I found this library, which looks great. However I’m having some trouble to understand how to use it. Can someone please give me an example? Something like view/js - controller - model/library would be very appreciated. I’m not new to codeigniter, but I’ve been working with asp.net mvc3 for the last year, so I feel a little rusty. Thanks!

  • #232 / Sep 11, 2011 11:06pm

    cryogenix

    90 posts

    Hello. I’ve been using datatables but never used the server side options. Now I want to use it in a codeigniter project and I found this library, which looks great. However I’m having some trouble to understand how to use it. Can someone please give me an example? Something like view/js - controller - model/library would be very appreciated. I’m not new to codeigniter, but I’ve been working with asp.net mvc3 for the last year, so I feel a little rusty. Thanks!

    well if you know CI’s active record then it’s pretty much like so.

    here’s a sample:

    $this->load->library('datatables');
    
    $this->datatables->select('name, salary')
                     ->from('tbl_employees')
                     ->where('salary >', '10000');
    
    $data['content'] = $this->datatables->generate();
    $this->load->view('ajax', $data);

    we also have a wiki page at our github repository here: https://github.com/IgnitedDatatables/Ignited-Datatables/wiki

  • #233 / Sep 12, 2011 7:54am

    nosuchnick

    3 posts

    Hey, thanks! In the meanwhile I managed to get it to work. What was missing was proper html and javascript to initialize the databable. I think this could be better documented somewhere. Neither you or datatables.net provide good complete examples in the websites. But oh, it’s working. Thank you

    BTW I’m returning json with echo data[‘result’], instead of loading another view. Is there any inconvenient?

  • #234 / Sep 12, 2011 11:08am

    zvir

    6 posts

    first, great library, thanks!

    second, if someone could help me with this, how to do conditional formatting of rows depending on one cell value?? i tried everything but nothing works…

  • #235 / Sep 12, 2011 12:58pm

    cryogenix

    90 posts

    Hey, thanks! In the meanwhile I managed to get it to work. What was missing was proper html and javascript to initialize the databable. I think this could be better documented somewhere. Neither you or datatables.net provide good complete examples in the websites. But oh, it’s working. Thank you

    BTW I’m returning json with echo data[‘result’], instead of loading another view. Is there any inconvenient?

    nah. it’s just that in strict MVC, I kinda like to adhere with no echo in controllers so I load it in a view.

    but there’s practically no difference if it works for you…

  • #236 / Sep 12, 2011 11:02pm

    nosuchnick

    3 posts

    ah, right! i see your point!

  • #237 / Sep 24, 2011 11:45am

    myface

    2 posts

    Hello

    First of all thank you for this library that allows me to use ajax datatable.

    I have a problem I blocked for a while. I would like to display a label based on a value in the database. Here’s the code:

    function documentsDisplayStatus($status)
    {
       if ($status=='4')
          return '<span class="tag green">Yes</span>';
       else
          return $status;
    }
    
    public function listener()
    {
        $this->load->library('datatables');
        
        $this->datatables->select("ID, VALIDATION")
             ->from("DOCUMENT")
             ->edit_column('VALIDATION', '$1', documentsDisplayStatus('VALIDATION'))
    }

    I have no rows with the text “Yes” in the table. But I have rows with value 4… I don’t understand…

    Thanks for your help.

    Regards

  • #238 / Sep 24, 2011 12:04pm

    umefarooq

    690 posts

    hi you have to do it like this

    ->edit_column('VALIDATION', '$1', "documentsDisplayStatus('VALIDATION')")

    if you need more fast you can use mysql if condition

    $this->datatables->select("ID, if(VALIDATION==4,'YES','No') as VALIDATION",TRUE)

    check mysql doc

    http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html#function_if

  • #239 / Sep 24, 2011 12:36pm

    myface

    2 posts

    Hi umefarooq,

    First of all, thanks for your help.

    I have tried this:

    ->edit_column('VALIDATION', '$1', "documentsDisplayStatus('VALIDATION')")

    “documentsDisplayStatus” is not executed but displayed in the table as text. So I have this:
    DOC00001   documentsDisplayStatus(‘VALIDATION’)
    DOC00002   documentsDisplayStatus(‘VALIDATION’)
    ...

    This code works:

    $this->datatables->select("ID, if(VALIDATION=4,'YES','No') as VALIDATION",TRUE)

    But I need to return html (Yes) so I’m not sure it’s a good idea.

    myFace

  • #240 / Sep 25, 2011 8:02am

    umefarooq

    690 posts

    Hi, how can i add a checkbox to datatables with this library through javascript is possible here is example we can add checkbox with in column

    http://aptasd.com.br/datatable/custom/

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases