ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Flexigrid CodeIgniter Implementation

September 05, 2008 4:07pm

Subscribe [63]
  • #16 / Sep 17, 2008 9:09am

    San2k

    10 posts

    is it possible to create editable fields in table?

  • #17 / Sep 17, 2008 5:01pm

    Armorfist

    121 posts

    You’ll have to ask Paulo that, he’s the creator of Flexigrid
    You can get more details / ask questions here http://groups.google.com/group/flexigrid?hl=en

  • #18 / Sep 21, 2008 5:18am

    daBayrus

    10 posts

    Hi Armorfist,

    Possible bugs found: :
    Bug 1. IE only. When I removed the buttons in the grid parameter, a runtime error has occurred. It says on Line 10, Error: expected identifier, string or number. I think the error is from the extra comma at the end of searchitems (Line 100). I removed it and added the comma at the start of buttons (Line 108).

    Generated script ...
    searchitems : [{display: 'ID', name : 'id', isdefault: true},
                   {display: 'Name', name : 'name'},
                   {display: 'Number Code', name : 'numcode'}], }); })

    Bug 2. I set the showTableToggleBtn to false in the grid parameters and it still shows. I removed the single quotes on Lines 66 and 68 in the helper file and it now works.

    if ($value == true)
      $grid_js .= $index.": true,";
    else
      $grid_js .= $index.": false,";

    Another bug in IE, when I toggle the grid, it complety disappears. I can’t replicate in on your demo though, maybe it was my css styles that was causing it. Still can’t solve it though. :down:

    I made some modifications on the library based on what suits me but basically it’s still the same. I merged the library and the helper file, i used a method on the primary controller instead of another controller (ajax) as the url of the flexigrid, and used active records to build the query. Here’s my version of the build_querys function

    public function build_query()
     {
       if ($this->post_info['swhere'])
         $this->CI->db->where($this->post_info['swhere']);
    
       $this->CI->db->order_by($this->post_info['sortname'], $this->post_info['sortorder']);
       $this->CI->db->limit($this->post_info['rp'], $this->post_info['limitstart']);
    }

    and to get the number of rows, here’s what I did

    $sql = $this->db->last_query();
    $sql = substr_replace($sql, '', strpos($sql, 'LIMIT'));
    $cnt = $this->db->query($sql);
    $rows = $cnt->num_rows()

    Good work on the latest version. Hoping for a editable cell in the future. 😉

    :wolv:

  • #19 / Sep 21, 2008 8:27am

    Armorfist

    121 posts

    Hello daBayrus,

    Thanks for the Bug fixes! Already updated the release.

    Also good idea with the active record. I don’t usually use active record to build SELECT querys, I’m still very used to build them by hand 😊.
    However, active record is great for avoiding some security issues and it works with several databases so I will implement it on the next release.😉

    Good work on the latest version. Hoping for a editable cell in the future. 😉

    Me too, but we have to ask Paulo for that 😊

    Thanks again!

  • #20 / Sep 21, 2008 9:03am

    Armorfist

    121 posts

    Hi again,

    The active record actually simplifies a lot! Again, great idea daBayrus 😊

    Already implemented the active record, however in the COUNT query I did something different than you daBayrus.
    In your approach, you get the last executed query, remove LIMIT and do a num_rows. This is fine for query’s with small results, but for query’s that return thousands of results executing the whole query just to count is not very good.
    So here’s my model:

    public function get_countries() 
        {
            //Select table name
            $table_name = "country";
            
            //Build contents query
            $this->db->select('id,iso,name,printable_name,iso3,numcode')->from($table_name);
            $this->CI->flexigrid->build_query();
            
            //Get contents
            $return['records'] = $this->db->get();
            
            //Build count query
            $this->db->select('count(id) as record_count')->from($table_name);
            $this->CI->flexigrid->build_query(FALSE);
            $record_count = $this->db->get();
            $row = $record_count->row();
            
            //Get Record Count
            $return['record_count'] = $row->record_count;
        
            //Return all
            return $return;
        }

    And I had to add a little parameter to the build_query function so it can strip the LIMIT from the count query:

    public function build_query($limit = TRUE)
        {
            if ($this->post_info['swhere'])
                $this->CI->db->where($this->post_info['swhere']);
        
            $this->CI->db->order_by($this->post_info['sortname'], $this->post_info['sortorder']);
            
            if ($limit)
                $this->CI->db->limit($this->post_info['rp'], $this->post_info['limitstart']);
        }

    Tell me what you think 😉

    Going to update the documentation and then upload this modification.

  • #21 / Sep 21, 2008 4:14pm

    Armorfist

    121 posts

    Just added the Active Record functionality to the implementation and updated documentation. The old query builder function was not removed for compatibility purposes. However I highly recommend to update.

    Download - http://flexigrid.eyeviewdesign.com/Flexigrid_CI_v0.35.rar
    Documentation - http://flexigrid.eyeviewdesign.com/index.php/flexigrid/example#s2

    😉

  • #22 / Sep 26, 2008 9:15am

    thor

    3 posts

    hi there,

    at first i must say very nice work 😊 sadly at implementing the example code i have some (small) problem which i dont get solved. running the example application i dont get any content into the grid. when i run the ajax controller itself i get the complete output from the database that is queried. so on the connection side to the database there seems to be no problem.

    so the problem that nothing is displayed must be either at creating the json output or reading/parsing it. at least i think so.

    i hope someone of you can help me to fix it cause i really like to use it 😉


    edit:
    i have the problem when i use firefox as browser. when displaying the example on ie i get the content in the grid, but i have to allow IE to get content from external data (there is a popup). the strange thing is when i run the demo on the example page (http://flexigrid.eyeviewdesign.com) it works with firefox and i theres also no popup on IE.

  • #23 / Sep 27, 2008 3:30am

    pixelazion

    21 posts

    hi, i’m having problem with the noConflict() thingy for prototype

    please help.. :(

    great stuff by the way 😊

  • #24 / Sep 27, 2008 5:49am

    manilodisan

    223 posts

    @pixelazion - change all the $ signs to jQuery

  • #25 / Sep 27, 2008 6:37am

    Armorfist

    121 posts

    hello thor,

    Can you tell me what kind of URL you are using to access the application? Like http://localhost/CodeIgniter/index.php/?

  • #26 / Sep 28, 2008 3:03am

    pixelazion

    21 posts

    @pixelazion - change all the $ signs to jQuery

    yes, i kind of did that but, still gives me an error, and grid is not displaying the data. i’m gonna try again.

    tnx for the reply

  • #27 / Sep 29, 2008 3:18am

    thor

    3 posts

    hello thor,

    Can you tell me what kind of URL you are using to access the application? Like http://localhost/CodeIgniter/index.php/?

    url was http://127.0.0.1/flexgrid/index.php/....

    and that was the problem. changed base_url from 127.0.0.1 to localhost 😝

  • #28 / Sep 29, 2008 6:00am

    geshan

    54 posts

    Can you make this grid pagination less, like live or rico grid demo here http://openrico.org/demos/livegrid.

  • #29 / Oct 02, 2008 8:25pm

    Armorfist

    121 posts

    Can you make this grid pagination less, like live or rico grid demo here http://openrico.org/demos/livegrid.

    Yes you can, edit the helper file, under helpers/flexigrid_helper.php, and on line 47 change
    $grid_js .= “usepager: true,”;
    to
    $grid_js .= “usepager: false,”;

    It will remove the pagination.

  • #30 / Oct 02, 2008 8:27pm

    Armorfist

    121 posts

    Just added the json_encode functionality for those who have JSON PHP Extension installed and updated documentation. You can still use the old system, however I highly recommend to update if you have this extension.

    Download - http://flexigrid.eyeviewdesign.com/
    Documentation - http://flexigrid.eyeviewdesign.com/index.php/flexigrid/example#s3

    *EDIT*
    There is a bug when there are no records to display. I’m fixing this tomorrow.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases