Current version: 1.1
New Features:
Export data to csv, xml, PDF
Jqgrid 3.7.2
General features
-List result
-add/delete/edit/search result
-Pagination
-jquery UI skins
Hi friends.
I was looking for a good crud for CodeIgniter, but found none.
So, I’ve been working on one that I work well and are easy to implement.
I’m using jqgrid, like frontend.
You can check the DEMO ![]()
======= SOURCE CODE ========
Overview
Basically, this CRUD library It arises from the necessity to provide basic administrative tasks and results display
Example
function index()
{
$this->load->library('datagrid');
$grid = $this->datagrid;
$grid->addField('id');
$grid->label('ID');
$grid->params(array('align' => "'center'",
'width' => 50,
'editable' => 'false',
'editoptions' => '{readonly:true,size:10}'
)
);
$grid->addField('name');
$grid->label('Name');
$grid->params(array('width' => 300,
'editable' => 'true',
'edittype' => "'text'",
'editrules' => '{required:true}'
)
);
$grid->addField('created');
$grid->label('Created');
$grid->params(array('width' => 300,
'editable' => 'true',
'edittype' => "'text'",
'editrules' => '{required:false,date:true}'
)
);
$grid->addField('description');
$grid->label('Description');
$grid->params(array('width' => 300,
'editable' => 'false',
'edittype' => "'text'",
'editoptions' => '{readonly:true,size:10}',
'editrules' => '{required:false}'
)
);
$select = $this->db->select()->from('crud_relation')->get()->result_array();
$arrSelect = array();
if(false == empty($select)){
foreach($select as $item){
$arrSelect[]= array($item['id'] => $item['description']);
}
}
$selectval = $grid->jsonresult($arrSelect);
$selectval = $grid->jqgridSelect($selectval);
$grid->addField('relation_id');
$grid->label('Description');
$grid->params(array('align' => "'center'",
'width' => 100,
'hidden' => 'true',
'editable' => 'true',
'edittype' => "'select'",
'editoptions' => '{value:":Select;' . $selectval . '",size:10}',
'editrules' => '{edithidden:true,required:true,integer:true}'
)
);
#GET url
$grid->setUrlget(site_url('welcome/getData/'));
#Set url
$grid->setUrlput(site_url('welcome/setData/'));
#show paginator
$grid->showpager(true);
#width
$grid->setWidth('600');
#height
$grid->setHeight('300');
#table title
$grid->setTitle('CRUD Example');
#show/hide navigation buttons
$grid->setAdd(true);
$grid->setEdit(true);
$grid->setDelete(true);
$grid->setSearch(true);
$grid->setRowNum(20);
#export buttons
$grid->setPdf(true,array('title' => 'Test pdf'));
$param['grid'] = $grid->deploy();
$this->load->view('crud',$param);
}
/**
* Get data result as json
*/
public function getData()
{
$this->load->library('datagrid');
$grid = $this->datagrid;
$response = $grid->getData('crud_test', array(array('table' => 'crud_relation',
'join' => 'crud_relation.id = crud_test.relation_id',
'fields' => array('description'))),array(),false);
$rs = $grid->jsonresult( $response);
echo $rs;
}
/**
* Put information
*/
public function setData()
{
$this->load->library('datagrid');
$grid = $this->datagrid;
$response = $grid->operations('crud_test','id');
}
======= VIEW DEMO ========
======= SOURCE CODE ========
Now is available the source code ======= HERE ========
Steps for implements in ours projects.
1)Copy the library (/system/application/libraries/Datagrid.php) in your project library application folder
2)Copy the view (/system/application/views/crud.php) in your views folders
3)Copy the JS’s libraries (/js/lib) into our JS folder.
4)Copy system/plugins/dompdf
and to_pdf_pi.php
thats it!
now visit http://www.trirand.com/jqgridwiki/, for learn to use the library datagrid.
I hope your comments.
