Looks good. I use something similar for my own projects. Interested in knowing how you handle large data lists. Let’s say 10,000+ records.
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
April 11, 2011 3:24am
Subscribe [77]#136 / Aug 08, 2011 6:05pm
Looks good. I use something similar for my own projects. Interested in knowing how you handle large data lists. Let’s say 10,000+ records.
#137 / Aug 11, 2011 10:07pm
Thanks, spectacular, You saved me a long time.
This system handles 34,000 records without any problems.
I have a problem: Flexigrid searches do not give any results. : (
#138 / Aug 11, 2011 10:51pm
I have a problem: Flexigrid searches do not give any results. : (
I know, do not use “all” search in flexigrid. it only work with one “type of register” (campo in spanish)
#139 / Aug 15, 2011 12:12pm
I been having problems installing the files.
I copied the files to my project, added the url helper and database libraries to may autoload.php, and finally connected to the database, but I end up with having only links like this:
‘>Offices | ‘>Employees | ‘>Customers | ‘>Orders | ‘>Products | ‘>Films
I think I may have missed something.
Using:
codeigniter 2.0.2
#140 / Aug 15, 2011 12:29pm
I been having problems installing the files.
I copied the files to my project, added the url helper and database libraries to may autoload.php, and finally connected to the database, but I end up with having only links like this:
‘>Offices | ‘>Employees | ‘>Customers | ‘>Orders | ‘>Products | ‘>Films
I think I may have missed something.
Using:
codeigniter 2.0.2
You must have your short_tags to on (it is at php.ini). In newer versions I replace all the code <?= to <?php echo , so no one to have the same problem again.
#141 / Aug 16, 2011 6:25am
Hi everybody,
I’m new to grocery crud and I’ld like to know how to set a field to insert/update data to my db as an input type password field and use the encryption MD5.
I’m integrating Ion_Auth into my framework and I need help on this topic.
Thanks in advance
#142 / Aug 16, 2011 10:02am
..and another question is about the date format…
Where I can change the date format before the insert/update operations?
I need it because my date format is dd-mm-yyyy and not as usual in us format.
I’ve changed the js files for jquery localization but I still can’t found where to change it into Grocery Crud.
Thanks in advance
Andy
#143 / Aug 19, 2011 10:18am
GroceryCRUD is AWESOME. I cannot thank you enough for the work you have put into it!!
I have a few questions/issues that I wanted to ask about.
1. The flexigrid seems to be the only way to reliably handle large datasets…but it has some bugs. Sometimes searching or changing pages will not update the grid. Anyone else notice this and find a workaround? (Maybe this is something we can fix by updating that component?)
2. I have a self-referencing table where parent_id -> id on the same table. It does not look like I can make this a proper lookup field in GroceryCRUD.
3. I have some nullable foreign keys - how can I make a clear button or otherwise allow the user to enter “null” as an acceptable value for a field?
Thanks again, this is all wonderful stuff that has really helped me.
#144 / Aug 21, 2011 6:38am
GroceryCRUD is AWESOME. I cannot thank you enough for the work you have put into it!!
I have a few questions/issues that I wanted to ask about.
1. The flexigrid seems to be the only way to reliably handle large datasets…but it has some bugs. Sometimes searching or changing pages will not update the grid. Anyone else notice this and find a workaround? (Maybe this is something we can fix by updating that component?)
2. I have a self-referencing table where parent_id -> id on the same table. It does not look like I can make this a proper lookup field in GroceryCRUD.
3. I have some nullable foreign keys - how can I make a clear button or otherwise allow the user to enter “null” as an acceptable value for a field?
Thanks again, this is all wonderful stuff that has really helped me.
For “nullable” or something custom that you want to create for something different than the default functionallity of grocery CRUD you can always work with callbacks. You can see working examples of some callbacks at: http://www.grocerycrud.com/crud/view/examples and you can see all the functions of callbacks at: http://www.grocerycrud.com/crud/view/options_functions
#145 / Aug 24, 2011 3:56pm
The New version of grocery CRUD is here and its full compatible with all the versions of CI 2. Below you can see the change log of the new version of the codeigniter CRUD library.
Bug Fix - Datetime picker now works fine to an empty input. It also works fine to the add operation.
When the edit and the delete is unset then dissapear the column Tools.
The default library/model is not in a third party but has been moved in the main codeigniter foldering for better functionality and to use it in both CI 1.7.x and CI 2.0.x .
Delete the grocery Exceptions Library. Everyone can create his own exception library. It was just an example.
Add new jquery version 1.6.2 and renewing some plugins.
Remove php short tags.
No direct script access allowed on the views.
Renaming function set_relation_1_n to set_relation_n_n. The functionallity has not change.
Removing the libraries MY_Output.php and MY_Loader.php from the core folder.
Removing the folder template. The template was just an example and confused lot of people.
Fully compatible with Codeigniter versions 1.7.x , 2.0.0 - 2.0.3.
Creation of new field type : “invisible”. Very useful if you use callbacks.
#146 / Aug 24, 2011 4:10pm
Thanks a Lot !!
One question: ¿The “Invisible fields” are the “hidden fields (add and edit form)” from http://www.grocerycrud.com/crud/view/future_features ? i.e. input type=hidden value=somevalue
#147 / Aug 24, 2011 4:38pm
Thanks a Lot !!
One question: ¿The “Invisible fields” are the “hidden fields (add and edit form)” from http://www.grocerycrud.com/crud/view/future_features ? i.e. input type=hidden value=somevalue
Actually yes and ... no. I think a lot about the hidden fields and it has really no reason to be there. That’s why I call it invisible and not hidden.
I have below an example of how it works:
function customers_management()
{
$crud = new grocery_CRUD();
$crud->set_table('customers');
$crud->columns('customerName','phone','city','country','salesRepEmployeeNumber','creditLimit');
$crud->display_as('salesRepEmployeeNumber','from Employeer')
->display_as('customerName','Name')
->display_as('contactLastName','Last Name');
$crud->set_subject('Customer');
$crud->set_relation('salesRepEmployeeNumber','employees','lastName');
$crud->change_field_type('contactLastName', 'invisible');
$crud->callback_before_insert(array($this,'just_test'));
$crud->callback_before_update(array($this,'just_test'));
$output = $crud->render();
$this->_example_output($output);
}
function just_test($post_array, $key = null)
{
$post_array['contactLastName'] = 'just_a_test';
return $post_array;
}(It is just an example to show you how it works).
So in this example, the field contactLastName does not appear at the add or edit form. But to the next step we can add the contactLastName and a value that we want to put. I fix it like that because:
1. It’s more safe , nobody can change the value , but the hidden field we can easily change it with a firebug.
2. It is more flexible if you are use to work with callbacks
3. It is invisible and it works fine in all the steps.
The function is on http://www.grocerycrud.com/crud/function_name/change_field_type and I will have a better example in my website ASAP with a really useful functionality of invisible field.
For any other question please tell me, just to know where a hidden_field can help…
#148 / Aug 24, 2011 7:16pm
Jhonny,
Imagine to tables: author(author_id,author_name,email_author) and book(book_id,author_id,isbn,book_name)
Next:
function authors()
{
$crud = new grocery_CRUD();
$crud->set_theme('flexigrid');
$crud->set_table('author');
// with this i add a link to the grocery crud display data
$crud->callback_column('Books',array($this,'goBooks'));
$crud->render()
}
function goBooks($value, $row)
{
// with this i add column with links to the grocery crud display data
$tmp = anchor_popup("crud/booksfromauthor/".$row->author_id,"my books");
return $tmp;
}
function booksfromauthor($author_id)
{
// because i can't pass a in url variable to grocery crud i use sessions
$this->session->set_userdata('author_id',$author_id);
redirect("crud/mybooks");
}
function mybooks()
{
// to manage (add/edit) books from ONE author
$author_id = $this->session->userdata('author');
$crud = new grocery_CRUD();
$crud->set_theme('flexigrid');
$crud->set_table('book');
$crud->hidden('author_id',$author_id); // to add only to one author ****
$crud->where('author_id',$author_id); // select only one author
$crud->render()
}If i have a lot of authors i would like insert books to preselected author… not select the author in the crud of the book.
Another solution to do the same (i think is better):
function mybooks()
{
// to manage (add/edit) books from ONE author
$author_id = $this->session->set_userdata('author');
$crud = new grocery_CRUD();
$crud->set_theme('flexigrid');
$crud->set_table('book');
$crud->frezee('author_id',$author_id); // the user see but CAN'T change the value ***
$crud->where('author_id',$author_id); // select only one author
$crud->render()
}*** my whish list to Grocery Crud: a hidden or frezee method. ¿Why? I need it to model the process in the application.
#149 / Aug 24, 2011 8:12pm
Jhonny,
Imagine to tables: author(author_id,author_name,email_author) and book(book_id,author_id,isbn,book_name)
Next:
function authors() { $crud = new grocery_CRUD(); $crud->set_theme('flexigrid'); $crud->set_table('author'); // with this i add a link to the grocery crud display data $crud->callback_column('Books',array($this,'goBooks')); $crud->render() } function goBooks($value, $row) { // with this i add column with links to the grocery crud display data $tmp = anchor_popup("crud/booksfromauthor/".$row->author_id,"my books"); return $tmp; } function booksfromauthor($author_id) { // because i can't pass a in url variable to grocery crud i use sessions $this->session->set_userdata('author_id',$author_id); redirect("crud/mybooks"); } function mybooks() { // to manage (add/edit) books from ONE author $author_id = $this->session->userdata('author'); $crud = new grocery_CRUD(); $crud->set_theme('flexigrid'); $crud->set_table('book'); $crud->hidden('author_id',$author_id); // to add only to one author **** $crud->where('author_id',$author_id); // select only one author $crud->render() }If i have a lot of authors i would like insert books to preselected author… not select the author in the crud of the book.
Another solution to do the same (i think is better):
function mybooks() { // to manage (add/edit) books from ONE author $author_id = $this->session->set_userdata('author'); $crud = new grocery_CRUD(); $crud->set_theme('flexigrid'); $crud->set_table('book'); $crud->frezee('author_id',$author_id); // the user see but CAN'T change the value *** $crud->where('author_id',$author_id); // select only one author $crud->render() }*** my whish list to Grocery Crud: a hidden or frezee method. ¿Why? I need it to model the process in the application.
Ok I understand what do you mean and you’re right. I will try to do it when I have time to a next version. For now there is a solution that you can work with. You can use callback_add_field and callback_edit_field (there are examples at the website). So you can both “freeze” and have hidden file too. So it will be something like that:
function mybooks()
{
// to manage (add/edit) books from ONE author
$author_id = $this->session->set_userdata('author');
$crud = new grocery_CRUD();
$crud->set_theme('flexigrid');
$crud->set_table('book');
$crud->callback_add_field('author_id',array($this,'add_field_callback_1'));
$crud->callback_edit_field('author_id',array($this,'edit_field_callback_1'));
$crud->render()
}
function add_field_callback_1()
{
$author_id = $this->session->set_userdata('author');
$author_name = $this->db->where('author_id',$author_id)->get('author')->author_name;
return "$author_name <input type='hidden' name='author_id' value='$author_id' />";
}
function edit_field_callback_1($value, $primary_key)
{
$author_id = $value;
$author_name = $this->db->where('author_id',$author_id)->get('author')->author_name;
return "$author_name <input type='hidden' name='author_id' value='$author_id' />";
}I hope it helps. I know that it will be easier with a hidden field, but for now try it like this.
#150 / Aug 25, 2011 5:23pm
CI 2.0.3 + HMVC + grocerycrud 1.1
Many thanks for this 3 wonderful tools ... just a little contribution.
Merci beaucoup pour ces 3 super outils ( en français ;o) )
#################################################
1/ in application/librairies/grocery_crud.php
#################################################
private function _theme_view($view, $vars = array(), $return = FALSE)
{
$ci = &get;_instance();
//If the _ci_view_path is not set we work with a codeigniter lower than the version 2.0.3
$ci_lt_2_0_3 = isset($ci->load->_ci_view_path) ? true : false;
if($ci_lt_2_0_3)
{
$orig_view_path = $ci->load->_ci_view_path;
$ci->load->_ci_view_path = $this->theme_path.$this->theme.'/views/';
}
else
{
$ci->load->add_package_path($this->theme_path.$this->theme.'/', TRUE);
}
if($return)
{
$return_view = $ci->load->view($view,$vars,true,$this->theme_path.$this->theme.'/views/');
if($ci_lt_2_0_3)
$ci->load->_ci_view_path = $orig_view_path;
else
$ci->load->remove_package_path( $this->theme_path.$this->theme.'/' );
//return $return_view;
}
else
{
$this->views_as_string = $ci->load->view($view,$vars,true,$this->theme_path.$this->theme.'/views/');
if($ci_lt_2_0_3)
$ci->load->_ci_view_path = $orig_view_path;
else
$ci->load->remove_package_path( $this->theme_path.$this->theme.'/' );
}
}###########################################################
2/ in application/third_party/MX/Loader.php
###########################################################
public function view($view, $vars = array(), $return = FALSE, $base = '') {
if(strpos($base,'grocery_crud')!==FALSE){
list($path, $view) = Modules::find($view, $this->_module, $base);
} else {
list($path, $view) = Modules::find($view, $this->_module, 'views/');
}
$this->_ci_view_path = $path;
return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
}###########################################################
3/ in application/third_party/MX/Modules.php
###########################################################
public static function find($file, $module, $base) {
$segments = explode('/', $file);
$file = array_pop($segments);
$file_ext = strpos($file, '.') ? $file : $file.EXT;
$path = ltrim(implode('/', $segments).'/', '/');
$module ? $modules[$module] = $path : $modules = array();
if ( ! empty($segments)) {
$modules[array_shift($segments)] = ltrim(implode('/', $segments).'/','/');
}
foreach (Modules::$locations as $location => $offset) {
foreach($modules as $module => $subpath) {
$fullpath = $location.$module.'/'.$base.$subpath;
if (is_file($fullpath.$file_ext)) return array($fullpath, $file);
if ($base == 'libraries/' AND is_file($fullpath.ucfirst($file_ext)))
return array($fullpath, ucfirst($file));
}
}
/* is the file in an application directory? */
if ($base == 'views/' OR $base == 'plugins/') {
if (is_file(APPPATH.$base.$path.$file_ext)) return array(APPPATH.$base.$path, $file);
show_error("Unable to locate the file: {$path}{$file_ext}");
}
/* grocery */
if(strpos($base,'grocery_crud')!==FALSE){
if (is_file($base.$path.$file_ext)) return array($base.$path, $file);
show_error("Unable to locate the file: {$path}{$file_ext}");
}
return array(FALSE, $file);
}