Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix if sRangeSeparator dont exist, ignore date range #32

Closed
wants to merge 2 commits into from
Closed

Conversation

ikarius6
Copy link
Contributor

Fix if sRangeSeparator dont exist, ignore date range

Fix if sRangeSeparator dont exist, ignore date range
What about developers than need the information of the query for a extended control, like print reports, stadistics, etc.. They need a way to access the query and get the list of nodes and name of columns, so I think add 2 new methods:

Added return_results(), similar to produce_output() but instead convert the list in JSON, it is return.
return array('aaData'=>$aaData,'sColumns'=>$sColumns);

Added request(), similar to generate() but is the public method to access to the query result, without paging to return all.

Controller example for use:
---------------------------------------
...
function my_csv_list(){
$this->load->helpers('datatables_helper');
$this->datatables->select("field1,field2,field3")
->from('table');
$results = $this->datatables->request();
$data['aaData'] = $results['aaData'];
$data['sColumns'] = $results['sColumns'];
//Example to produce a report in CSV format
$this->load->view('downloads/csv',$data);
}
-------------------
View downloads/csv:

<?
header('Content-Encoding: UTF-8');
header('Content-type: text/csv; charset=UTF-8');
header('Content-Disposition: attachment; filename=list.csv');
echo "\xEF\xBB\xBF";
if(!empty($sColumns)) echo implode(",",$sColumns)."\r\n";
if(!empty($aaData)) foreach($aaData as $ad){
	echo implode(",",$ad)."\r\n";
}
@cryogenix cryogenix closed this in bcce6d7 Jul 24, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant