Welcome Guest, Not a member yet? Register   Sign In
Flexigrid CodeIgniter Implementation
#11

[eluser]Guro[/eluser]
[quote author="San2k" date="1221244093"]Hi!
Thanks . very nice!

I have a little problem with SORTABLE tables. I'am setting row to be sortable - but he is not. There is no picture on the name of the row and when i click on it - nothing happens. What can be? Everything else works good.[/quote]

same problem here
#12

[eluser]Armorfist[/eluser]
[quote author="Guro" date="1220984035"]hello, big thanks for this nice project.
as i see in demo there are column Actions and delete button, but it didn't works.
im trying to make it work, i have added your test function to delete button but no success, as i understand test function needs 2 arguments com & grid, com is just a string but grid? how can i get grid name?[/quote]

You are right, I didn't add AJAX delete to the buttons under "Actions". Those where only there to exemplify a situation where you can add images to the columns. Never thought about it to make it work, but I'll try. I understood your problem, and maybe you should ask Paulo how to get the grid name. If I figure it out sooner I'll post here.

[quote author="San2k" date="1221244093"]Hi!
Thanks . very nice!

I have a little problem with SORTABLE tables. I'am setting row to be sortable - but he is not. There is no picture on the name of the row and when i click on it - nothing happens. What can be? Everything else works good.[/quote]

I just noticed I have the same problem locally. Going to try to figure it out. Probably some javascript failure in the helper.
#13

[eluser]Armorfist[/eluser]
Ok about the sort problem:

In the helper file (/application/helpers/flexigrid.php) go to line 59 and replace that line with:
Code:
$grid_js .= "{display: '".$value[0]."', ".($value[2] ? "name : '".$index."', sortable: true," : "")." width : ".$value[1].", align: '".$value[3]."'".(isset($value[5]) && $value[5] ? ", hide : true" : "")."},";

It should work after that.

I'm going to rewrite the helper so it can take all the possible parameters for flexigrid. Will post it here for testing as soon as its done.
#14

[eluser]Armorfist[/eluser]
Ok, just finished some modifications to the Helper file and released v0.3.
Unfortunately I changed the parameters on the helper "build_grid_js" function a bit, so you guys have to change it in your projects, but now you have allot more flexibility in terms of setting up the grid:

Changes:
- Fixed some helper bugs
- Removed "width" and "height" parameter and replaced it with an array where you can insert any FlexiGrid parameter you want. Read more about these changes here.
- The $buttons variable in the "build_grid_js" function is now the last parameter and optional

With the new Grid Parameters array, you can have several configurations stored in a CI config file so this is great for a site that has several templates.

Hope you enjoy.
#15

[eluser]San2k[/eluser]
[quote author="Armorfist" date="1221251151"]Ok about the sort problem:

In the helper file (/application/helpers/flexigrid.php) go to line 59 and replace that line with:
Code:
$grid_js .= "{display: '".$value[0]."', ".($value[2] ? "name : '".$index."', sortable: true," : "")." width : ".$value[1].", align: '".$value[3]."'".(isset($value[5]) && $value[5] ? ", hide : true" : "")."},";

It should work after that.

I'm going to rewrite the helper so it can take all the possible parameters for flexigrid. Will post it here for testing as soon as its done.[/quote]

Thanks!!
#16

[eluser]San2k[/eluser]
is it possible to create editable fields in table?
#17

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

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

Code:
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.

Code:
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

Code:
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

Code:
$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

[eluser]Armorfist[/eluser]
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 Smile.
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.Wink

[quote author="daBayrus" date="1222003135"]
Good work on the latest version. Hoping for a editable cell in the future. ;-)
[/quote]
Me too, but we have to ask Paulo for that Smile

Thanks again!
#20

[eluser]Armorfist[/eluser]
Hi again,

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

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:
Code:
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:

Code:
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 Wink

Going to update the documentation and then upload this modification.




Theme © iAndrew 2016 - Forum software by © MyBB