Welcome Guest, Not a member yet? Register   Sign In
Jqgrid CRUD 1.1[NEW]
#1

[eluser]vicman[/eluser]
Code:
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 Smile
======= SOURCE CODE ========

Overview
Basically, this CRUD library It arises from the necessity to provide basic administrative tasks and results display

Example
Code:
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);
    }

Code:
/**
* 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;            
}

Code:
/**
* 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.
#2

[eluser]ElToro[/eluser]
nice following... I started play around to do own admin CRUD, but looks like I really don't have enough time now to make anything usefully. So I am waiting to see what you cooked up. So keep on going Smile
#3

[eluser]vicman[/eluser]
Now u can see a Demo
#4

[eluser]ElToro[/eluser]
looking good.

Is your library doing the validation also and how to control that?

I can share one of the main point I had in my CRUD plan:
I like the way you can control the stuff, but most of the parameters could be be guessed from the DB table if table name was given. Then things like width, datatype, validation etc could be guessed from the table info (Sure leaving possibility to override settings)
This also makes possible to set up setting file to give default validation for certain datatypes etc...
#5

[eluser]vicman[/eluser]
off course, i would like know your suggestions and new funcionalities
#6

[eluser]Unknown[/eluser]
Hi vicman,

I have the same needs for non-profit organization.
would you mind to already share your library.
I'm very interested in test-driving this (and assist if/when needed)

Thanks,

Eric.
#7

[eluser]vicman[/eluser]
sure, in a few days I'll upload the source code.

Pacience Wink
#8

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

thats it!

now visit http://www.trirand.com/jqgridwiki/, for learn to use the library datagrid.

I hope your comments.
#9

[eluser]vicman[/eluser]
Someone has tested?
#10

[eluser]Rolly1971[/eluser]
demo looks good.

i just downloaded it, once i have it setup i will let you know how well it works out.

i was thinking of making my own. Not hard really, specially if you use a js framework like jquery.

if this works well enough, i might not have to make my own Smile




Theme © iAndrew 2016 - Forum software by © MyBB