Part of the EllisLab Network
   
2 of 7
2
Flexigrid CodeIgniter Implementation
Posted: 12 September 2008 10:14 AM   [ Ignore ]   [ # 11 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  145
Joined  10-18-2007
Guro - 09 September 2008 08:13 AM

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?

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.

San2k - 12 September 2008 08:28 AM

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.

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

 Signature 

Eye View Design - Creative Web Solutions
CI FlexiGrid - FlexiGrid on CI Implementation (Deprecated)

Profile
 
 
Posted: 12 September 2008 10:25 AM   [ Ignore ]   [ # 12 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  145
Joined  10-18-2007

Ok about the sort problem:

In the helper file (/application/helpers/flexigrid.php) go to line 59 and replace that line with:

$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.

 Signature 

Eye View Design - Creative Web Solutions
CI FlexiGrid - FlexiGrid on CI Implementation (Deprecated)

Profile
 
 
Posted: 12 September 2008 01:28 PM   [ Ignore ]   [ # 13 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  145
Joined  10-18-2007

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.

 Signature 

Eye View Design - Creative Web Solutions
CI FlexiGrid - FlexiGrid on CI Implementation (Deprecated)

Profile
 
 
Posted: 17 September 2008 05:25 AM   [ Ignore ]   [ # 14 ]  
Summer Student
Total Posts:  11
Joined  09-07-2008
Armorfist - 12 September 2008 10:25 AM

Ok about the sort problem:

In the helper file (/application/helpers/flexigrid.php) go to line 59 and replace that line with:

$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.

Thanks!!

Profile
 
 
Posted: 17 September 2008 07:09 AM   [ Ignore ]   [ # 15 ]  
Summer Student
Total Posts:  11
Joined  09-07-2008

is it possible to create editable fields in table?

Profile
 
 
Posted: 17 September 2008 03:01 PM   [ Ignore ]   [ # 16 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  145
Joined  10-18-2007

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

 Signature 

Eye View Design - Creative Web Solutions
CI FlexiGrid - FlexiGrid on CI Implementation (Deprecated)

Profile
 
 
Posted: 21 September 2008 03:18 AM   [ Ignore ]   [ # 17 ]  
Summer Student
Avatar
Total Posts:  14
Joined  04-11-2007

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. downer

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. wink

:wolv:

Profile
 
 
Posted: 21 September 2008 06:27 AM   [ Ignore ]   [ # 18 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  145
Joined  10-18-2007

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

daBayrus - 21 September 2008 03:18 AM

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

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

Thanks again!

 Signature 

Eye View Design - Creative Web Solutions
CI FlexiGrid - FlexiGrid on CI Implementation (Deprecated)

Profile
 
 
Posted: 21 September 2008 07:03 AM   [ Ignore ]   [ # 19 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  145
Joined  10-18-2007

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:

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 wink

Going to update the documentation and then upload this modification.

 Signature 

Eye View Design - Creative Web Solutions
CI FlexiGrid - FlexiGrid on CI Implementation (Deprecated)

Profile
 
 
Posted: 21 September 2008 02:14 PM   [ Ignore ]   [ # 20 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  145
Joined  10-18-2007

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

wink

 Signature 

Eye View Design - Creative Web Solutions
CI FlexiGrid - FlexiGrid on CI Implementation (Deprecated)

Profile
 
 
   
2 of 7
2
 
‹‹ DataMapper 1.6.0      Freshbooks Class ››
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 120592 Total Logged-in Users: 56
Total Topics: 126626 Total Anonymous Users: 2
Total Replies: 665667 Total Guests: 451
Total Posts: 792293    
Members ( View Memberlist )