[updated 24/11/2012] Dependent dropdown (library)
Posted 18 December 2012 - 10:07 AM
Posted 18 December 2012 - 14:47 PM
before ([background=rgb(255, 255, 255)]that's how I had to put it to work are the relationships set_relation_n_n[/background])
[img]http://s12.postimage.org/dfpgiz6jx/trabajadores_before.jpg[/img]
after ?
[img]http://s13.postimage.org/sa96mdy53/trabajadores_after.jpg[/img]
regards
Posted 18 December 2012 - 19:33 PM
Do you don't like consejo_popular field on the page?
Posted 18 December 2012 - 19:56 PM
Posted 18 December 2012 - 22:46 PM
[background=rgb(255, 255, 255)]in short, is to see if the library can work with relationships set_relation_n_n [/background]
[background=rgb(255, 255, 255)]greetings and thanks for replying[/background]
Posted 19 December 2012 - 10:53 AM
Posted 19 December 2012 - 14:06 PM
Posted 26 December 2012 - 10:38 AM
[b] [size=4]Storing Hierarchical Data in a Database[/size][/b]
[img]http://s13.postimage.org/m6k9gfbzb/sitepoint_tree.gif[/img] [img]http://sitepointstatic.com/graphics/table01.gif[/img]
THX.
Posted 27 December 2012 - 21: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
Posted 27 December 2012 - 23: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//admin/Comercios/grilla/get_items/id_subcategoria/2
The method get_items, what should be returned? An example? thanks
Posted 28 December 2012 - 00:32 AM
"url" => base_url (). 'index.php/admin /'. __class__. '/'. __FUNCTION__. '/',
Very useful the library. Thanks
Posted 28 December 2012 - 13:27 PM
Victor: 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
[/quote]
This method return Javascript
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 [b]not related[/b] 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?
Posted 03 January 2013 - 12:12 PM
Posted 03 January 2013 - 12:14 PM
Posted 03 January 2013 - 13: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'));
Posted 03 January 2013 - 13:13 PM
It had nothing to do with your library after all!
Thank you very much for your help!
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!
[/quote]
[quote name='victor' timestamp='1357218102' post='4959']
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'));
[/quote]
Shame on me!!! I didn't search for similar issues before posting an issue!
Solution for the problem mentioned before is here: /topic/254-set-relation-breaks-processing-of-field-with-same-name-returned/#entry982
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.
[sharedmedia=core:attachments:420]
[sharedmedia=core:attachments:421]
[sharedmedia=core:attachments:422]
[sharedmedia=core:attachments:424]
List with relation works ok:
[sharedmedia=core:attachments:425]
but I m not able to add record with dependent dropdown, first choice is ok but I can't choose second list:
[sharedmedia=core:attachments:426]
Can u help me?
Thanks
Michele
Posted 07 January 2013 - 12:33 PM
$config = array(
'main_table' => '[color=#008800][size=2][background=rgb(248, 248, 248)]dd_goods[/background][/size][/color]',
'main_table_primary' => '[color=#008800][size=2][background=rgb(248, 248, 248)]goods_id[/background][/size][/color]',
'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!
[quote name='mirr0r' timestamp='1357561272' post='5008']
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
[/quote]