CodeIgniter Forums
Ignited DataTables - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Ignited DataTables (/showthread.php?tid=32173)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37


Ignited DataTables - El Forum - 08-04-2011

[eluser]LoganPHP[/eluser]
First i like to say thanks again for your great plugin.

I have a problem in edit_column.

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="'.site_url(" title="View" class="with-tip">View</a>&nbsp;&nbsp;<a href="'.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.


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="'.site_url(" title="View" class="with-tip">View</a>&nbsp;&nbsp;<a href="'.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



Ignited DataTables - El Forum - 08-04-2011

[eluser]ηυмвєяσηє[/eluser]
Well, This is wrong
Code:
->edit_column('inv.status', $this->status('$1'), 'inv.status')

You need to use a helper file as i said before. Try:
Code:
->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


Ignited DataTables - El Forum - 08-04-2011

[eluser]Chauzu[/eluser]
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


Ignited DataTables - El Forum - 08-04-2011

[eluser]ηυмвєяσηє[/eluser]
can i see your javascript setup and ajax listener ?


Ignited DataTables - El Forum - 08-04-2011

[eluser]Chauzu[/eluser]
sure,
Extract from the listener
Code:
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
Code:
$('#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


Ignited DataTables - El Forum - 08-04-2011

[eluser]ηυмвєяσηє[/eluser]
well, it's been added in 2011-07-14..
Code:
"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:
Code:
"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 ?


Ignited DataTables - El Forum - 08-04-2011

[eluser]ηυмвєяσηє[/eluser]
I have committed a small fix for that. improved filtering.

Can you download the library and try the codes below ?
Code:
$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');


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

or you can do simply (it should work.) :
Code:
$('#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.'"');}


Ignited DataTables - El Forum - 08-04-2011

[eluser]Chauzu[/eluser]
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.


Ignited DataTables - El Forum - 08-05-2011

[eluser]cryogenix[/eluser]
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.


Ignited DataTables - El Forum - 08-05-2011

[eluser]Chauzu[/eluser]
[quote author="cryogenix" date="1312553341"]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.[/quote]

Thanks, now it's working Big Grin