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

[eluser]cipmang[/eluser]
[quote author="ηυмвєяσηє" date="1310656958"]controller :
Code:
function datatabless()
    {
      $this->load->library('datatables');
      $this->datatables
        ->select('nim, nama, kelas, telp, alamat')
        ->from('data');

        echo $this->datatables->generate();
    }
    function showpage()
    {
      $this->load->view('vdatatables');
    }

and go to main/showpage..
datatabless is your ajax listener and its output will be array.[/quote]

thanks a lot ηυмвєяσηє,
yeah,.....
i like this share...
i'll share it to with other people...

[eluser]meddiecap[/eluser]
Hi,

Wow, very sweet class! I'm playing with it a bit trying to get searching per column working. I'm getting this error:

Call to a member function where() on a non-object [..] on line 236, when using

Code:
"aoSearchCols": [
    null,
    null,
    null,
    null,
    null,
    null,
    null,
    null,
    null,
    { "sSearch": "My filter" },
    null,
    { "sSearch": "^[0-9]", "bEscapeRegex": false }
]
(i have 12 columns)

It concerns this line:
Code:
$this->ar->where($this->select[$mColArray[$i]].' like', '%'.$this->ci->input->post('sSearch_' . $i).'%');

I'm using the current version of Datatables.php

Hope you can help!
Thanks

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

Thanks for that. Now it fixed on github.

Im afraid, regular expressions on filtering are not supported by the library at the moment.

Regards,
Yusuf

[eluser]pmsfo[/eluser]
Just Added Group By Fuction to datatables, it works for me.

Code:
protected $groupbys        = array();

/**
    * Generates the Group By portion of the query
    *
    * @param string $tables
    * @return mixed
    */
    public function group_by($tables)
    {
      $this->groupbys[] = $tables;
      $this->ci->db->group_by($tables);
      return $this;
    }

Now you can use

$this->datatables->group_by('job.jobid,job.name,job.starttime,job.endtime,
job.jobfiles,job.jobbytes,job.jobstatus,job.level,
jobmedia.mediaid,media.volumename');

Signature
______________________________________________
www.newitperson.com
www.newitperson.com/reportula

[eluser]pmsfo[/eluser]
How Can I do this, change the value of column to image by if clause example:

Code:
if ($row['jobstatus'] == "T" ){
                
                $row['jobstatus']= ("<img  src='".base_url()."assets/images/icons/accept.png'>");
            }else if ($row['jobstatus'] == "A" ) {
                $row['jobstatus']= ("<img  src='".base_url()."assets/images/ico_stop_16.png'>");
             }else  {  
                
                $row['jobstatus']= ("<img  src='".base_url()."assets/images/ico_inactive_16.png'>");
            }
            if ($row['level'] == "I" ){
                $row['level']= ("<img  src='".base_url()."assets/images/incBackup.png'>");
            }else{
                $row['level']= ("<img  src='".base_url()."assets/images/fullBackup.png'>");


How i can do this with the library ?

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


Code:
$this->load->helper("Datatables"); // create datatables_helper.php in helpers folder
$this->load->library("Datatables");
..
..
->edit_column('jobstatus', "<img src='".base_url()."assets/images/$1'>", 'callback_getjobstatus(jobstatus)' )
->edit_column('level', "<img  src='".base_url()."assets/images/$1'>", 'callback_getjoblevel(level)');

// add these functions to datatables_helper.php
Code:
function getjobstatus ($jobstatus) {
if($jobstatus == "T")
   return "icons/accept.png";
elseif($jobstatus == "A")
   return "ico_stop_16.png";
else
   return "ico_inactive_16.png";
}

function getjoblevel ($level) {
      return ($level == "I")? "incBackup.png" : "fullBackup.png";
}
(strongly advised to do this in javascript, if you can)


About 'GROUP BY', I thought this before, However It is better to use the code below for some reasons.
[quote author="ηυмвєяσηє" date="1309445845"]you should use 'GROUP BY' in subqueries.

For Example :
Code:
$this->load->library("Datatables");

$this->datatables
->select('pages.id as pageid, title')
->from('(SELECT id,title,user_id FROM pages GROUP BY user_id) as pages')
->join('users', 'users.id = pages.user_id', 'left' )
->select('username');

echo $this->datatables->generate();

its not a very good example but i think u got the idea ^^

Regards,
Yusuf[/quote]

[eluser]lordoffriends[/eluser]
How to override the Query string parameter in editable datagrid ?The default query string is generated by the datagrid(i.e adding an id parameter which has the value of the first column cell of the datatable).When i click on the specific row,and click on the delete button,the delete url is called as given in the code.This url is initialized in the code.What i want to ask is ,how do i override the url at runtime(i.e adding my row data specific query string in the url) ????

This is the code i am using...
------------------------------------------------------------------------

$(document).ready( function () {
oTable=$('#example').dataTable({
"bProcessing": true,
"sAjaxSource": "http://localhost/questions/Test/listener",
"fnInitComplete": function (){
$(oTable.fnGetNodes()).click(function (){
var aPos = oTable.fnGetPosition( this );
var aData = oTable.fnGetData( aPos[0] );
});
},
aoColumns: [ { "bVisible": false} , null, null, null, null ]
}
).makeEditable({
sUpdateURL: "UpdateData.php",
sAddURL: "AddData.php",
sAddHttpMethod: "GET",
sDeleteURL: "http://localhost/questions/Test/DeleteData",
sDeleteHttpMethod: "GET",
});
} );
-------------------------------------------------------------------

Waiting for reply.

[eluser]cryogenix[/eluser]
although your question is datatables specific, we're kind enough to answer you Wink

take note of the submitdata parameter here: http://www.datatables.net/examples/api/editable.html

with that in mind, you can do some editing like this:

Code:
'submitdata':
        function(value, settings)
        {
          var k = -1, e = this, column;

          while(e){
            if('previousSibling' in e)
            {
              e = e.previousSibling;
              k = k + 1;
            }
            else
            {
              k = -1;
              break;
            }
          }

          switch(k)
          {
            case 1 : column = 'name'; break;
            case 2 : column = 'email'; break;
            default: column = 'password'; break;
          }

          return { 'column' : column, 'operator_id' : this[removed].firstChild[removed] }
        }

[eluser]pmsfo[/eluser]
For the images what i did was this


Code:
$this->datatables->edit_column('job.level', '<img  src='.base_url().'>', 'job.level');


and change the name of file.

For example i only have 2 types of jobs levels "I" and "F" so i change the filename from incBackup.png for I.png and F.png.

i think in this case its better than creating a database helper.

But it's nice to know that is possible to create helpers and using functions.

thank you very much for you r reply

[eluser]lordoffriends[/eluser]
This is the code...

var oTable;
var aData;
var row;

$(document).ready(function() {

$('#example tbody tr').live('click', function (event) {

$(oTable.fnSettings().aoData).each(function (){
$(this.nTr).removeClass('row_selected');
});

$(event.target[removed]).addClass('row_selected');
aData = oTable.fnGetData(this); // get datarow
row = $(this).closest("tr").get(0);
});

/* Add a click handler for the delete row */
$('#delete').click( function() {
$.ajax({
type: "GET",
url: "&lt;?php echo base_url(); ?&gt;Test/DeleteData",
data: "id="+aData[0],
success: function(msg){
//oTable.fnDeleteRow(aData);
var anSelected = fnGetSelected( oTable );
oTable.fnDeleteRow( anSelected[0] );
oTable.fnDeleteRow(oTable.fnGetPosition(row));
}
});
} );

/* Init the table */
oTable = $('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "&lt;?php echo base_url(); ?&gt;Test/Listener",
"sPaginationType": "full_numbers",
"iDisplayLength": 1,
"bSortClasses": false,
"aoColumns": [ { "bVisible": false} , null, null ]
} );


} );
/* Get the rows which are currently selected */
function fnGetSelected( oTableLocal )
{
var aReturn = new Array();
var aTrs = oTableLocal.fnGetNodes();

for ( var i=0 ; i<aTrs.length ; i++ )
{
if ( $(aTrs[i]).hasClass('row_selected') )
{
aReturn.push( aTrs[i] );
}
}
return aReturn;
}
What is happening :-
The server side data gets loaded when page is called for the first time.
The server side data gets deleted on clicking delete link.But the Datatable doesnt refresh after deleting a row on server.The usual "processing" message comes after deletion on server.It stays there.The UI row stays there highlighted with message "Processing" in the middle of the page

What i have observed is :-
1)The response of Ajax source after the delete url is called is this :-
{"sEcho":1,"iTotalRecords":1,"iTotalDisplayRecords":1,"aaData":[["11","PD101-DH1234","adsasd"]],"sColumns":"PartId,PartNumber,PartDescription"}
2)After using firebug,i observed no abnormalities.Both the delete and get source requests are executed perfectly with response OK.
3)I am using FireFox 4.1
4)I am using DataTables 1.8.1 build.

Now Question :-
What do i change in the above code so that the datatable UI row gets deleted and datatable refreshes to bring the remaining rows ???




Theme © iAndrew 2016 - Forum software by © MyBB