Jump to content


[updated 24/11/2012] Dependent dropdown (library)

Dependent dropdown categories ajax dropdown Categories and sub-categories

  • Please log in to reply
347 replies to this topic

#341 greyson

greyson

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 08 April 2018 - 10:31 PM

field 2 inactive, someone could help



#342 avi

avi

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 09 April 2018 - 09:06 AM

Hi Guys,

 

It's a great library..

 

I have some problem, the second select list is updated but it's still disabled.. 

 

The select option is updated accordingly, however the JQuery Chosen is still disabled and it's not populated..

 

I wonder if someone has similar situation



#343 priyanka

priyanka

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 08 May 2018 - 05:25 AM

Hi, I am new to grocery crud library. For dependent dropdown, I used gc_dependent_select library. first dropdown work fine but second dropdown is disabled on page load as well as onchange firts dropdown. Please help me out

Please find the attached screenshot. URL: https://www.screenca.../t/Xg88C9Th4byT

 

thanks

 



#344 sandeep88

sandeep88

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 16 May 2018 - 06:31 AM

Hi, I'm a newbie to GC and I have managed to install it successfully. Now I'm trying to add the dependent select box with this library. I'm getting values in the country dropdown, but state and city dropdowns seem to be disabled. I think I'm having issues with including js files, please find attached files. Also, I have created the foreign key between tables country, state and city.

 

Pasting the controller function 

***********************************************************************

public function locs_management()
{
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('locations');
$crud->set_relation('con_id','country','name');
$crud->set_relation('st_id','state','st_name');
$crud->set_relation('ct_id','city','ct_name');
$this->load->library('gc_dependent_select');
 
$fields = array(
 
// first field:
'con_id' => array( // first dropdown name
'table_name' => 'country', // table of country
'title' => 'name', // country title
'relate' => null // the first dropdown hasn't a relation
),
// second field
'st_id' => array( // second dropdown name
'table_name' => 'state', // table of state
'title' => 'st_name', // state title
'id_field' => 'id', // table of state: primary key
'relate' => 'con_id', // table of state:
'data-placeholder' => 'select state' //dropdown's data-placeholder:
 
),
// third field. same settings
'ct_id' => array(
'table_name' => 'city',
//'where' =>"post_code>'167'",  // string. It's an optional parameter.
//'order_by'=>"state_title DESC",  // string. It's an optional parameter.
'title' => 'id: {id} / city : {ct_name}',  // now you can use this format )))
'id_field' => 'city_id',
'relate' => 'st_id',
'data-placeholder' => 'select city'
)
);
 
$config = array(
'main_table' => 'locations',
'main_table_primary' => 'id',
"url" => base_url() . __CLASS__ . '/' . __FUNCTION__ . '/', //path to method
//'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"
);
//print_r ($crud);
        //print_r ($fields);
        //print_r ($config);
$categories = new gc_dependent_select($crud, $fields, $config);
$js = $categories->get_js();
$output = $crud->render();
$output->output.= $js;
$this->_example_output($output);
 
 
}

***********************************************************************

Thanks in advance.



#345 ekobudi79

ekobudi79

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 13 June 2018 - 05:43 AM

Hi Victor,

 

I have same problem like everyone, the first dropdown can be used, when i select one option the first dropdown the second dropdown still disabled. I am using GC 1.6 and your library version 1.5.

Please help me. Thanks.



#346 kingwash

kingwash

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 23 January 2019 - 11:29 AM

Helllo, i'm new to Grocery Crud. I need help on this dependent dropdown library.

 

I have downloaded (Gc_dependent_select.php)  but don't now how to use.

Please attach the database tables to your reply.

 

Thanks in advance



#347 andreagam

andreagam

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 25 February 2020 - 06:16 PM

Hi all and thanks Victor for this awesome library.
I just wanted to ask if it's possible to set a default selected value in the first dropdown.

Thanks for your help!

 

Andrew



#348 kadejo

kadejo

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 10 May 2020 - 08:27 PM

Hi all!

 

First of all I want to pay respects to victor and of course to  web-johnny, I really appreciate your work and generosity open sourcing & sharing it.

 

I want to report that this library works perfectly on GC v1.6.3 too (as of May 2020), and also share two tips to ease its use:

 

1) In my case I had to add index.php, to the url parameter, as Victor already had answered in some other post in this same thread. 

 "url" => base_url() .'index.php/'. __CLASS__ . '/' . __FUNCTION__ . '/',

2) I think the next question is answered as follows, as I have two different dependent dropdowns on the same CRUD (linked to the same father dropdown, but for sure it is the same solution if they are cascaded dropdowns).

 



Hi Victor,

 

I have same problem like everyone, the first dropdown can be used, when i select one option the first dropdown the second dropdown still disabled. I am using GC 1.6 and your library version 1.5.

Please help me. Thanks.

 

For two (or more) dependent dropdowns segment_name parameter is mandatory, so you have to give it a different name for each dropdown (it is the last parameter so pay attention to add an ending ',' on previous line):

'segment_name' =>'second_select' 

Best regards,

 

Carlos







Also tagged with one or more of these keywords: Dependent dropdown, categories, ajax, dropdown, Categories and sub-categories

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users