

[updated 24/11/2012] Dependent dropdown (library)
#101
Posted 18 December 2012 - 10:07 AM
#102
Posted 18 December 2012 - 02:47 PM
before (that's how I had to put it to work are the relationships set_relation_n_n)

after ?

regards
#103
Posted 18 December 2012 - 07:33 PM
Do you don't like consejo_popular field on the page?
#104
Posted 18 December 2012 - 07:56 PM
#105
Posted 18 December 2012 - 10:46 PM
in short, is to see if the library can work with relationships set_relation_n_n
greetings and thanks for replying
#106
Posted 19 December 2012 - 10:53 AM
#107
Posted 19 December 2012 - 02:06 PM
#108
Posted 26 December 2012 - 10:38 AM
Storing Hierarchical Data in a Database


THX.
#109
Posted 27 December 2012 - 09:54 PM
I'm not clear that these method return.
$js = $categories->get_js();
And because they are concatenated:
$output = $crud->render();
$output->output.= $js;
I'll be testing the library to post comments.
Thanks
#110
Posted 27 December 2012 - 11:04 PM
$config = array(
'main_table' => 'comercios',
'main_table_primary' => 'id_comercio',
"url" => base_url() . '/admin/'.__CLASS__ . '/' . __FUNCTION__ . '/',
'ajax_loader' => base_url().PATH_IMG.'/admin/ajax-loader.gif', // path to ajax image.
);
When selecting a value in the first select, then attempts to call:
http://localhost//ad..._subcategoria/2
The method get_items, what should be returned? An example? thanks
#111
Posted 28 December 2012 - 12:32 AM
"url" => base_url (). 'index.php/admin /'. __class__. '/'. __FUNCTION__. '/',
Very useful the library. Thanks
#112
Posted 28 December 2012 - 01:27 PM
This method return JavascriptVictor: As would be a standard view?
I'm not clear that these method return.
$js = $categories->get_js();
And because they are concatenated:
$output = $crud->render();
$output->output.= $js;
I'll be testing the library to post comments.
Thanks
#113
Posted 03 January 2013 - 12:02 PM
Victor, I was trying to use a callback_column and I might have found a drawback of your library.
I used in a grid view(using datatables) that has dependent fields, a callback column but on a field that is not related at all with dependent dropdowns,
e.g.
$this->grocery_crud->columns('customers_id','activities_id','groups_id','date','description','date_inserted'); $this->grocery_crud->callback_column('customers_id',array($this,'_callback_attend_edit_url')); $fields = array( 'activities_id' => array( 'table_name' => 'activities', 'title' => '{year} {description}', 'relate' => null), 'groups_id' => array( 'table_name' => 'groups', 'title' => '{day} {hour} {description}', 'id_field' => 'id', 'relate' => 'activities_id', 'data-placeholder' => 'Επιλογή Γκρούπ Δρaστηριοτήτων' ) );
As you can see, I try to put a callback on customers_id which isn't one of the two fields that I am using for dependent dropdowns(activities_id,groups_id).
Try it, I am afraid we cannot use at all a callback column anywhere else when your library is used!
Just for the sake of testing I tried the exact same code on a view that doesn't use the dependent dropdowns library and is working perfectly!
Any ideas?
#114
Posted 03 January 2013 - 12:12 PM
#115
Posted 03 January 2013 - 12:14 PM
#116
Posted 03 January 2013 - 01:01 PM
in your case :
$this->grocery_crud->set_relation('customers_id','customers','{lname} {fname}');and
$this->grocery_crud->callback_column('customers_id',array($this,'_callback_attend_edit_url'));
#117
Posted 03 January 2013 - 01:13 PM
It had nothing to do with your library after all!
Thank you very much for your help!
#118
Posted 04 January 2013 - 03:53 AM
Possibly a bug or something that the core developer hasn't mentioned on the documentation!
It had nothing to do with your library after all!
Thank you very much for your help!
As I see we can't use the callback_column when we use the set_relation for these columns.
in your case :$this->grocery_crud->set_relation('customers_id','customers','{lname} {fname}');and$this->grocery_crud->callback_column('customers_id',array($this,'_callback_attend_edit_url'));
Shame on me!!! I didn't search for similar issues before posting an issue!
Solution for the problem mentioned before is here: http://www.grocerycr...urned/#entry982
#119
Posted 07 January 2013 - 12:21 PM
I test your library and I m not able to work.
my controller is copy&past from your first post, just changed this string:
"url" => base_url() . __CLASS__ . '/' . __FUNCTION__ . '/', path to method
in
"url" => base_url() . __CLASS__ . '/' . __FUNCTION__ . '/'
and deleted optional:
'ajax_loader' => base_url() . 'ajax-loader.gif' // path to ajax-loader image. It's an optional parameter 'segment_name' =>'Your_segment_name' // It's an optional parameter. by default "get_items"
So this is:
public function goods() { $crud = new grocery_CRUD(); $crud->set_table('dd_goods'); $crud->set_relation('goods_country', 'dd_country', 'country_title'); $crud->set_relation('goods_state', 'dd_state', 'state_title'); $crud->set_relation('goods_city', 'dd_city', 'city_title'); $this->load->library('gc_dependent_select'); // settings $fields = array( // first field: 'goods_country' => array( // first dropdown name 'table_name' => 'dd_country', // table of country 'title' => 'country_title', // country title 'relate' => null // the first dropdown hasn't a relation ), // second field 'goods_state' => array( // second dropdown name 'table_name' => 'dd_state', // table of state 'title' => 'state_title', // state title 'id_field' => 'state_id', // table of state: primary key 'relate' => 'country_ids', // table of state: 'data-placeholder' => 'select state' //dropdown's data-placeholder: ), // third field. same settings 'goods_city' => array( 'table_name' => 'dd_city', 'where' =>"post_code>'167'", // string. It's an optional parameter. 'order_by'=>"state_title DESC", // string. It's an optional parameter. 'title' => 'id: {city_id} / city : {city_title}', // now you can use this format ))) 'id_field' => 'city_id', 'relate' => 'state_ids', 'data-placeholder' => 'select city' ) ); $config = array( 'main_table' => 'dd_goods', 'main_table_primary' => 'goods_id', "url" => base_url() . __CLASS__ . '/' . __FUNCTION__ . '/' ); $categories = new gc_dependent_select($crud, $fields, $config); // first method: //$output = $categories->render(); // the second method: $js = $categories->get_js(); $output = $crud->render(); $output->output.= $js; $this->_example_output($output); }
table in database is your table "dd_goods", "dd_country", "dd_state" and "dd_city" with sample data.




List with relation works ok:

but I m not able to add record with dependent dropdown, first choice is ok but I can't choose second list:

Can u help me?
Thanks
Michele
#120
Posted 07 January 2013 - 12:33 PM
$config = array(
'main_table' => 'dd_goods',
'main_table_primary' => 'goods_id',
'url' => base_url() . 'index.php/' . strtolower(__CLASS__) . '/' . strtolower(__FUNCTION__) . '/',
'ajax_loader' => base_url() . 'style/images/'. 'ajax-loader.gif'
);
strlower() might not needed in your case!
hi,
I test your library and I m not able to work.
my controller is copy&past from your first post, just changed this string:"url" => base_url() . __CLASS__ . '/' . __FUNCTION__ . '/', path to method
in"url" => base_url() . __CLASS__ . '/' . __FUNCTION__ . '/'
and deleted optional:'ajax_loader' => base_url() . 'ajax-loader.gif' // path to ajax-loader image. It's an optional parameter 'segment_name' =>'Your_segment_name' // It's an optional parameter. by default "get_items"
So this is:public function goods() { $crud = new grocery_CRUD(); $crud->set_table('dd_goods'); $crud->set_relation('goods_country', 'dd_country', 'country_title'); $crud->set_relation('goods_state', 'dd_state', 'state_title'); $crud->set_relation('goods_city', 'dd_city', 'city_title'); $this->load->library('gc_dependent_select'); // settings $fields = array( // first field: 'goods_country' => array( // first dropdown name 'table_name' => 'dd_country', // table of country 'title' => 'country_title', // country title 'relate' => null // the first dropdown hasn't a relation ), // second field 'goods_state' => array( // second dropdown name 'table_name' => 'dd_state', // table of state 'title' => 'state_title', // state title 'id_field' => 'state_id', // table of state: primary key 'relate' => 'country_ids', // table of state: 'data-placeholder' => 'select state' //dropdown's data-placeholder: ), // third field. same settings 'goods_city' => array( 'table_name' => 'dd_city', 'where' =>"post_code>'167'", // string. It's an optional parameter. 'order_by'=>"state_title DESC", // string. It's an optional parameter. 'title' => 'id: {city_id} / city : {city_title}', // now you can use this format ))) 'id_field' => 'city_id', 'relate' => 'state_ids', 'data-placeholder' => 'select city' ) ); $config = array( 'main_table' => 'dd_goods', 'main_table_primary' => 'goods_id', "url" => base_url() . __CLASS__ . '/' . __FUNCTION__ . '/' ); $categories = new gc_dependent_select($crud, $fields, $config); // first method: //$output = $categories->render(); // the second method: $js = $categories->get_js(); $output = $crud->render(); $output->output.= $js; $this->_example_output($output); }
table in database is your table "dd_goods", "dd_country", "dd_state" and "dd_city" with sample data.
List with relation works ok:
but I m not able to add record with dependent dropdown, first choice is ok but I can't choose second list:
Can u help me?
Thanks
Michele
Edited by David Oster, 07 January 2013 - 12:41 PM.
Also tagged with one or more of these keywords: Dependent dropdown, categories, ajax, dropdown, Categories and sub-categories
Support →
Grocery CRUD Enterprise →
Problem with the setRelation dropdown.Started by dhouwen, 04 Feb 2020 ![]() |
|
![]() |
||
Support →
I have a question →
CSRF Regenerate Not WorkingStarted by satheesh, 10 Dec 2019 ![]() |
|
![]() |
||
Support →
I have a question →
Grocery Crud dependent dropdownStarted by rim, 21 Nov 2019 ![]() |
|
![]() |
||
Development →
Extra coding / Plugins →
DependentDropdown(custom query) + PostAjaxCallbacks + MoreButtons + MoreUnsets + CustomColumnStarted by genya, 29 Jul 2019 ![]() |
|
![]() |
||
Support →
Grocery CRUD Enterprise →
Disable dropdown in search filters and change to text inputStarted by Indeax, 26 Nov 2018 ![]() |
|
![]() |
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users