Welcome Guest, Not a member yet? Register   Sign In
Why can't we have simpler data grid listing table for codeigniter ?
#1

[eluser]aman_tuladhar[/eluser]
I wonder, why can't we have something simpler like this in codeigniter and get the data grid listing display done ?

Code:
$config = array(
    'query' => $this->db->get_where('table', array($condition)),
);

echo $data_grid->render(($config));


Normally query object should have all the information needed for table grid display.
Why can't we just use it and generate table grid listing ?


Fed up of setting up table list manually or javascript data grids, I decide to do write some experimental library code for this feature. Not sure if this is good or right way to do it. All suggestion are welcome you can email be at aman.tuladhar[at]gmail.com

Just a prototype code for moment. Using ocular library at moment to test idea and implementation. My ultimate goal would be to have one liner configuration code and make it independent of any other 3rd party codeigniter libraries.

You can find demo at http://happy-igniter.co.cc/ca_gridview
you can download code at https://github.com/amant/ca_gridview


What do you get when you combine Joomla, Break.com and love of Codeigniter framework?
you will get Happy-Igniter CMS ofcourse Smile
A simple joomla look a like cms, to showcase the implementation of this Data Grid View.

You can find demo at http://happy-igniter.co.cc/happy_cms/admin.php
You can download code at https://github.com/amant/happy_cms

A simple example:
Code:
class Test extends CI_Controller
{    
    function example()
    {  
        $grid_params = array(
        // Here you define db object
            'set_query' => $this->db->get_where('country', array('region_id !=' => 0)),

        // Here you setup pagination stuff and what should be initial order by display column
            'set_pagination' => array(
                'enable' => true,
                'initialize' => array('base_url' => site_url('example/example_1'), 'per_page'=>25, 'num_links' => 5),
                'order_field' => 'country_id',
                'order_type' => 'ASC',
                'offset' => 0
            ),

        // Here you setup the column, and define what type of column is it
            'set_column' => array(
                'country_id' => array(
                    'title' => 'Country-ID',
                    'type' => array('text'),
                ),

                'region_id' => array(
                    'title' => 'Region-ID',
                    'type' => array('text'),
                ),

                'country_name' => array(
                    'title' => 'Country',
                    'type' => array('text'),              
                ),
            
                'country_3_code' => array(
                    'title' => 'CODE 3',
                    'type' => array('text'),
                ),

                'country_2_code' => array(
                    'title' => 'CODE 2',
                    'type' => array('text'),
                )
            )
        );

        $this->ca_gridview->render_grid($grid_params);
        $this->ocular->render();  
    }
}
#2

[eluser]John_Betong_002[/eluser]
This is definitely going into my toolbox.

I am impressed, excellent solution, all I have to do now is to think of a problem.


 
 
 
#3

[eluser]aman_tuladhar[/eluser]
Thanx John Smile. Codeigniter is a lovely little framewok, but lack of some kind of simpler data grid has been nagging me for quite some time now. Trying to figure out if this approach can be applicable in real projects. I wonder, changing and adding stuff to url segment is good idea or not?
#4

[eluser]Basketcasesoftware[/eluser]
I might have an application for it already. I was just considering what I needed for a display list. This might do. FYI, contents of cart in a commercial site is what I had in mind. I was going to use the HTML Table class, but this looks MUCH better!
#5

[eluser]aman_tuladhar[/eluser]
hummm... cart you say, this should be interesting. I never had cart in mind while creating the library non the less it should be able to handle cart. Let me know if you need any help with this.
#6

[eluser]bEz[/eluser]
For the Action Column, have you considered individually enabling/disabling either the Edit or Delete instead of Both or None.
#7

[eluser]Basketcasesoftware[/eluser]
[quote author="aman_tuladhar" date="1300984360"]hummm... cart you say, this should be interesting. I never had cart in mind while creating the library non the less it should be able to handle cart. Let me know if you need any help with this.[/quote]

Check your inbox. You have two messages from me.
#8

[eluser]aman_tuladhar[/eluser]
[quote author="bEz" date="1301003112"]For the Action Column, have you considered individually enabling/disabling either the Edit or Delete instead of Both or None.[/quote]
Yes you are correct most of the time Edit, Delete are the common links that will be displayed in action column. What I have experienced is as feature for backend grows, links in action column grows too. You might need various kinds of links like preview, maintenance, quick email, indicators, etc. So, I thought may be multiple array might be better way to define action column, it gives you the flexibility.

Code:
array(
'edit' => array(
        ...
    ),
'delete' => array(
        ...
    ),
'quick email' => array(
        ...        
    )
),




Theme © iAndrew 2016 - Forum software by © MyBB