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]
  • #211 / Aug 04, 2011 1:01pm

    LoganPHP

    15 posts

    First i like to say thanks again for your great plugin.

    I have a problem in edit_column.

    public function invoice_listener()
        {
            $this->load->library('datatables');
            $this->datatables
                ->select("inv.id,inv.status,inv.invoice_no,inv.patient_name,inv.ref_doctor,inv.hospital",FALSE)
                ->from('tb_invoices AS inv')
                ->where('inv.lab_id',$this->session->userdata('lab_id'))
                ->edit_column('inv.status', $this->status('$1'), 'inv.status')
                ->add_column('action', '<a href="http://%27.site_url" title="View" class="with-tip">View</a>  <a href="http://%27.site_url" title="Report" class="with-tip">Report</a>', 'inv.id');
        
            echo $this->datatables->generate();
        }
        
        function status($s)
        {
          return $s;
        }

    It is working properly(return values are 0’s or 1’s).

    But i have a problem in following code.

    public function invoice_listener()
        {
            $this->load->library('datatables');
            $this->datatables
                ->select("inv.id,inv.status,inv.invoice_no,inv.patient_name,inv.ref_doctor,inv.hospital",FALSE)
                ->from('tb_invoices AS inv')
                ->where('inv.lab_id',$this->session->userdata('lab_id'))
                ->edit_column('inv.status', $this->status('$1'), 'inv.status')
                ->add_column('action', '<a href="http://%27.site_url" title="View" class="with-tip">View</a>  <a href="http://%27.site_url" title="Report" class="with-tip">Report</a>', 'inv.id');
        
            echo $this->datatables->generate();
        }
        
        function status($s)
        {
            if($s==1)
            {
                return 'Enable';
            }
            else
            {
                return 'Disable';
            }
        }

    It returns ‘Disable’ for every rows.

    I have just added conditional statement in second one,otherwise same as first one.But i i don’t know why this doesn’t work properly.

    Please help me.

    Thanks in advance,
    Logan

  • #212 / Aug 04, 2011 2:00pm

    ηυмвєяσηє

    109 posts

    Well, This is wrong

    ->edit_column('inv.status', $this->status('$1'), 'inv.status')

    You need to use a helper file as i said before. Try:

    ->edit_column('inv.status', '$1', 'status(inv.status)')

    and copy your function to in a helper file. I have explained how to do that in my previous post.

    Regards,
    Yusuf

  • #213 / Aug 04, 2011 5:28pm

    Chauzu

    6 posts

    Hi, i got a problem with the last version, I’m using multifilter at the view to post parameters to the controller with sSearch vars.
    The problem is that these parameters automatically generate like conditions in the controller query. I need these parameters to establish a range for the query, but my query ends with something like: 

    date>parameter1  
    date<parameter2
    date like “%parameter1%” //generated automatically
    date like “%parameter2%” //generated automatically

    So there is no middle results.

    This don’t happen with the version 0806c88(2011-06-22) so i suppose there has been a change in the functionality , any ideas how to remove that conditions? or a different approach to establish a range for the query?

    thanks for your help

  • #214 / Aug 04, 2011 5:36pm

    ηυмвєяσηє

    109 posts

    can i see your javascript setup and ajax listener ?

  • #215 / Aug 04, 2011 6:05pm

    Chauzu

    6 posts

    sure,
    Extract from the listener

    if ($this->input->post('sSearch_8')) $date1=$this->input->post('sSearch_8');
    if ($this->input->post('sSearch_12'))$date2=$this->input->post('sSearch_12');
        
         $this->datatablesold
           ->select('cas_id, cas_nsiniestro,compania_id,cas_estado,cas_fingreso,cas_fingreso as cas_fingreso2,cas_cinspeccion')
           ->from('al_caso')
           ->join ('al_inspectores', 'al_caso.insp_id=al_inspectores.insp_id','left')
           ->select('insp_nombre');
        
         
         if (isset($date1)){ $date1=fechaAdb($date1); $this->datatablesold->where('cas_fingreso >= "'.$date1.'"');}
         if (isset($date2)) {$date2=fechaAdb($date2);$this->datatablesold->where('cas_fingreso <= "'.$date2.'"');}

    cas_fingreso is the table field i need the range from, i repeated it at the query to be able to post the two range parameters from the view. i wonder if that is the problem, but works ok in this old version.

    extract from the view

    $('#search').click(function() {
        
            oTable.fnMultiFilter( { 
                                    "cas_fingreso":$("#ffecha1").val(),
                                    "cas_fingreso2":$('#ffecha2').val()
                                    });
        
      })

    I replaced datatables to datatablesold to keep using the old version that works in this particular case.

    thanks again

  • #216 / Aug 04, 2011 6:24pm

    ηυмвєяσηє

    109 posts

    well, it’s been added in 2011-07-14..

    "aoSearchCols": [
            null,
            null,
            null,
            null,
            null,
            { "sSearch": "sometext" },   /// refers to sSearch_5, automatically adds "LIKE '%sometext%'"
            null,
            null
        ],


    im thinking to improve functionality of the aoSearchCols. I wanna do:

    "aoSearchCols": [
            null,
            null,
            null,
            { "sSearch": "<150, >80" }, // refers to sSearch_3, adds column < '150' AND column > '80'
            null,
            { "sSearch": "sometext" },   /// refers to sSearch_5, automatically adds "LIKE '%sometext%'"
            null,
            { "sSearch": "some, text" }  /// refers to sSearch_7, "LIKE '%some%'" AND LIKE '%text%'" 
        ],

    It is an idea for now. what do you think ?

  • #217 / Aug 04, 2011 7:30pm

    ηυмвєяσηє

    109 posts

    I have committed a small fix for that. improved filtering.

    Can you download the library and try the codes below ?

    $this->datatable
           ->select('cas_id, cas_nsiniestro,compania_id,cas_estado,cas_fingreso,cas_fingreso as cas_fingreso2,cas_cinspeccion')
           ->from('al_caso')
           ->join ('al_inspectores', 'al_caso.insp_id=al_inspectores.insp_id','left')
           ->select('insp_nombre');

    $('#search').click(function() {
        
            oTable.fnMultiFilter( { 
                                    "cas_fingreso": '>=' + $("#ffecha1").val(),
                                    "cas_fingreso2": '<=' + $('#ffecha2').val()
                                    });
        
      })

    or you can do simply (it should work.) :

    $('#search').click(function() {
       oTable.fnMultiFilter( { 
                              "cas_fingreso": '>=' + $("#ffecha1").val() + ',<=' + $('#ffecha2').val()
                             });
      })


    there is no need
    if ($this->input->post(‘sSearch_8’)) $date1=$this->input->post(‘sSearch_8’);
    if ($this->input->post(‘sSearch_12’))$date2=$this->input->post(‘sSearch_12’);
    and
    if (isset($date1)){ $date1=fechaAdb($date1); $this->datatablesold->where('cas_fingreso >= "'.$date1.'"');}
    if (isset($date2)) {$date2=fechaAdb($date2);$this->datatablesold->where('cas_fingreso <= "'.$date2.'"');}

  • #218 / Aug 05, 2011 12:19am

    Chauzu

    6 posts

    Thanks a lot for your work, i downloaded the library and the range filter worked ok, but a new problem came out.

    I got a json response but no table is generated, checking the json response against JSONLint, i noticed that now the response is not valid, then i went back to the previous library and the response is valid. Some of my fields are texts and got carriage returns inside, I’m wondering if there is a change in the way the json response is made at your library.

  • #219 / Aug 05, 2011 6:09am

    cryogenix

    90 posts

    apparently, the charset detection function is buggy and unstable. we made changes and reverted back to making json encoding with charset selection optional. you may now download the latest release with these issues fixed.

  • #220 / Aug 05, 2011 8:51pm

    Chauzu

    6 posts

    apparently, the charset detection function is buggy and unstable. we made changes and reverted back to making json encoding with charset selection optional. you may now download the latest release with these issues fixed.

    Thanks, now it’s working :D

  • #221 / Aug 06, 2011 3:53am

    okbang

    4 posts

    Mother’s Day is arriving, making it the period given our budget in order to seem to invest in a reward together with exhibit the great absolutely adore and because of excellent favorite mommies. In spite of this, at this time achieve their objectives . reasonably nearly impossible to find the right mother daily things. A good number of our own new mothers continue to comply with the fashion; fot that reason, this kind items while tulips or sometimes lps are not to be pleasing enough to that lead. We have to amount most of the precious ought to have and select the most appropriate products.Now, My goal is to propose some kind of special and so designer christmas presents available for way and so hot and spicy parents.———————
    ————————-
    ————————————-

  • #222 / Aug 16, 2011 4:30pm

    bryanftw

    1 posts

    I love this library! It’s made my life so much easier over the past few days, I really appreciate all the work that went into it!

    Everything is working wonderfully except for the search bar. I have to re-query the same table once I know what the User’s Id is because users can belong to other users based on their roles. For instance, a User with a role of Agent has a GeneralAgent and and MarketingOrg. The GA and the MO are in the same table so I take the IDs and get the names from them.

    Once this happens, the columns contain names instead of IDs. The search bar doesn’t seem to be able to search the new column values. Is there a work around for this?

    My Listener looks like this:

    $this->load->helper('datatables');
            $this->datatables->select('Contracts.Id, Contracts.GeneralAgentID AS Ga, Contracts.AgentID AS Agent, Contracts.SellerID AS Seller, Locations.Name AS Location, Contracts.CoverageStartDate AS Date, Plans.PlanName, Plans.MOUnitCost')
                             ->where('Contracts.MarketingOrgID', $_SESSION['Id'])
                             ->from('Contracts')
                             ->join('Plans', 'Contracts.PlanID = Plans.Id')
                             ->join('Locations', 'Contracts.LocationID = Locations.Id')
                             ->edit_column('Ga', '$1', 'get_name_by_id(Ga)')
                             ->edit_column('Agent', '$1', 'get_name_by_id(Agent)')
                             ->edit_column('Seller', '$1', 'get_name_by_id(Seller)')
                             ->edit_column('Date', '$1', 'dateformat(Date)')
  • #223 / Aug 17, 2011 6:05am

    samseko

    16 posts

    Hi, how do i remove the pagination - that is, i want to show all items on the same page?!

    I thought “sDom”: ‘f’ or ‘t’ did that in the html script area but it isnt doing anything?

    [Edit] NM, i just commented $this->get_paging(); in the library.

  • #224 / Aug 29, 2011 3:30pm

    wr5aw

    32 posts

    When searching an integer field for a value of zero, no search is performed. Any other value besides zero works fine.

    Edit:

    I’ve found the issue and posted the following fix on github:

    At line 237:

    Change

    if($this->ci->input->post('sSearch_' . $i]) && 
      $this->ci->input->post('sSearch_' . $i) != '' && 
      in_array($mColArray[$i], $columns))

    To

    if(isset($_POST['sSearch_' . $i]) && 
      $this->ci->input->post('sSearch_' . $i) != '' && 
      in_array($mColArray[$i], $columns))
  • #225 / Aug 31, 2011 1:31am

    hyperfire

    53 posts

    How to use this using CSRF protection true on config?
    On most of my ajax calls the trick is to use jquerycookie and pass the cookie val on post data like this:

    [removed][removed]
    var form_data = {
      aInput: formValue,
      ci_csrf_token: $.cookie("ci_csrf_token")
    };
    $.ajax({
       type: "POST",
       url: "<?php echo base_url(); ?>ajax/doSomething",
       data: form_data,
       dataType: 'json'
    });

    How can I do the same for

    'fnServerData': function(sSource, aoData, fnCallback){
                $.ajax({
                    'dataType': 'json',
                    'type': 'POST',
                    'url': sSource,
                    'data': aoData,
                    'success': fnCallback
                });
            }

    Or there’s another way to send the cookie value?
    Thanks

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

ExpressionEngine News!

#eecms, #events, #releases