30/07
2013
Wallogit.com
2017 © Pedro Peláez
add in app.config, (*1)
return array(
'providers'=>array(
...
...
'Witooh\GridDataprovider\GridDataproviderServiceProvider',
),
'alias'=>array(
'''
...
'JqGrid' => 'Witooh\GridDataprovider\Facades\JqGrid',
),
);
There are 2 classes have to use - Criteria - JqGrid, (*2)
Example, (*3)
public function dataProvider()
{
//Create new Criteria with table name
$criteria = new Criteria('Post');
//If title is not empty, it will generate sql where (AND) condition
$criteria->compare('title', Input::get('title'));
//If content is not empty, it will generate sql where (OR) condition
$criteria->orCompare('title', Input::get('content'));
//use Laravel Query Builder
$criteria->query->leftJoin('comment', 'comment.post_id', '=', 'post.id');
//make the JqGrid dataprovider
//Dont care of the parameter which jqgrid send to the sever
//This class will detected Input by itself.
//Frist param is the criteria object
//Second param is primary_key for jqgrid default is 'id'
//return data array
return JqGrid::make($criteria, 'post.id');
}