hai,
first i thanks for very useful library. i have one problem working with ajax_gorcery_crud library. while editing the fields no success message has n't been occuring.
please give me appropriate solution
⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠
Posted 05 June 2015 - 06:22 AM
hai,
first i thanks for very useful library. i have one problem working with ajax_gorcery_crud library. while editing the fields no success message has n't been occuring.
please give me appropriate solution
Posted 08 June 2015 - 22:50 PM
Hi
i'm trying to find a function like this library, but my data structure it's a little diferente:
CREATE TABLE ruta ( ruta_id INT PRIMARY KEY, ruta VARCHAR(50) ); CREATE TABLE empresa( empresa_id INT PRIMARY KEY, empresa VARCHAR(50), tipo ENUM('CLIENTE','PROVEEDOR') ); CREATE TABLE tarifa ( tarifa_id INT PRIMARY KEY, ruta_id VARCHAR(50), empresa_id VARCHAR(50), ); CREATE TABLE carta( id INT PRIMARY KEY, ruta_ruta_id INT, cliente_cliente_id INT, proveedor_proveedor_id INT, FOREIGN KEY (`ruta_ruta_id`) REFERENCES `ruta` (`ruta_id`), FOREIGN KEY (`cliente_cliente_id`) REFERENCES `empresa` (`empresa_id`) FOREIGN KEY (`proveedor_proveedor_id`) REFERENCES `empresa` (`empresa_id`) );
At the moment the relation is:
$crud->set_relation('ruta_ruta_id','ruta','ruta'); $crud->set_relation('clientes_cliente_id','empresas','empresa',array('tipo' => 'CLIENTE')); $crud->set_relation('proveedor_proveedor_id','empresas','empresa',array('tipo' => 'PROVEEDOR'));
I want to display a dropbox of ruta and a dropbox of cliente and proveedor but only those wich have ruta chosen.
But this dependecy it is given in a fourth table tarifas
I tried with
$crud->set_relation('clientes_cliente_id','tarifas','empresa_id'); $crud->set_relation('proveedor_proveedor_id','tarifas','empresa_id'); $crud->set_relation_dependency('clientes_cliente_id','ruta_ruta_id','ruta_ruta_id'); $crud->set_relation_dependency('proveedor_proveedor_id','ruta_ruta_id','ruta_ruta_id');
But i am not able to filter cliente y proveedor and i don't get the name of empresa but the id number
Is there a way to use the table tarifas usig this realtions?
$crud->set_relation('ruta_ruta_id','ruta','ruta'); $crud->set_relation('clientes_cliente_id','empresas','empresa',array('tipo' => 'CLIENTE')); $crud->set_relation('proveedor_proveedor_id','empresas','empresa',array('tipo' => 'PROVEEDOR'));
thanks in advance!
Posted 09 June 2015 - 02:25 AM
Hi
i'm trying to find a function like this library, but my data structure it's a little diferente:
CREATE TABLE ruta ( ruta_id INT PRIMARY KEY, ruta VARCHAR(50) ); CREATE TABLE empresa( empresa_id INT PRIMARY KEY, empresa VARCHAR(50), tipo ENUM('CLIENTE','PROVEEDOR') ); CREATE TABLE tarifa ( tarifa_id INT PRIMARY KEY, ruta_id VARCHAR(50), empresa_id VARCHAR(50), ); CREATE TABLE carta( id INT PRIMARY KEY, ruta_ruta_id INT, cliente_cliente_id INT, proveedor_proveedor_id INT, FOREIGN KEY (`ruta_ruta_id`) REFERENCES `ruta` (`ruta_id`), FOREIGN KEY (`cliente_cliente_id`) REFERENCES `empresa` (`empresa_id`) FOREIGN KEY (`proveedor_proveedor_id`) REFERENCES `empresa` (`empresa_id`) );At the moment the relation is:
$crud->set_relation('ruta_ruta_id','ruta','ruta'); $crud->set_relation('clientes_cliente_id','empresas','empresa',array('tipo' => 'CLIENTE')); $crud->set_relation('proveedor_proveedor_id','empresas','empresa',array('tipo' => 'PROVEEDOR'));I want to display a dropbox of ruta and a dropbox of cliente and proveedor but only those wich have ruta chosen.
But this dependecy it is given in a fourth table tarifas
I tried with
$crud->set_relation('clientes_cliente_id','tarifas','empresa_id'); $crud->set_relation('proveedor_proveedor_id','tarifas','empresa_id'); $crud->set_relation_dependency('clientes_cliente_id','ruta_ruta_id','ruta_ruta_id'); $crud->set_relation_dependency('proveedor_proveedor_id','ruta_ruta_id','ruta_ruta_id');But i am not able to filter cliente y proveedor and i don't get the name of empresa but the id number
Is there a way to use the table tarifas usig this realtions?
$crud->set_relation('ruta_ruta_id','ruta','ruta'); $crud->set_relation('clientes_cliente_id','empresas','empresa',array('tipo' => 'CLIENTE')); $crud->set_relation('proveedor_proveedor_id','empresas','empresa',array('tipo' => 'PROVEEDOR'));thanks in advance!
I almost resolve this creating a view v_empresa_ruta
VIEW v_empresa_ruta{ empresa_id INT, empresa VARCHAR(50), ruta_id INT, empresa_tipo ENUM('CLIENTE','PROVEEDOR') }
And my dependecy
$crud->set_relation('ruta_ruta_id','ruta','{ruta}'); $crud->set_primary_key('empresa_id', 'v_empresa_ruta'); $crud->set_relation('clientes_cliente_id','v_empresa_ruta','empresa',array('tipo_empresa' => 'CLIENTE')); $crud->set_relation('proveedor_proveedor_id','v_empresa_ruta','empresa',array('tipo_empresa' => 'PROVEEDOR')); $crud->set_relation_dependency('clientes_cliente_id','ruta_ruta_id','ruta_id'); $crud->set_relation_dependency('proveedor_proveedor_id','ruta_ruta_id','ruta_id');
but the filters or tipo_empresa doesn't work, as a worr around i would divide the view in v_cliente_ruta and v_proveedor_ruta
Posted 02 October 2015 - 07:17 AM
Hi i am trying to use this dependent dropdown but it gives error in ajax_grocery_CRUD. which is:
Fatal error: Access level to ajax_grocery_CRUD::$state_code must be protected (as in class Grocery_CRUD) or weaker in D:\xampp\htdocs\bookncook_admin\application\libraries\ajax_grocery_crud.php on line 261
Severity: Compile Error
Message: Access level to ajax_grocery_CRUD::$state_code must be protected (as in class Grocery_CRUD) or weaker
Filename: libraries/ajax_grocery_crud.php
Line Number: 261
Backtrace:
Some one can fix it please...
Posted 05 October 2015 - 05:06 AM
Well.. open the grocerycrud library... find the definition of the variable $state_code & make it protected from private.. that should do the trick.
Posted 07 October 2015 - 18:41 PM
Hi folks! great work around this fabulous library, I have two questions
a) does this work for n_n relations
b) where is the most updated code
Thanks in advance
Juan
Posted 12 October 2015 - 08:22 AM
Sorry this dose not work on the n_n relation. If you need something like that - then u need to write up the code for the same. I remember an incedent where it was single relation to n_n relation dependency where based on the option selected, values on n_n was changed. Such stuff was achieved by custom JS / PHP code.
Posted 23 February 2016 - 09:17 AM
So helpless :(
How do you make it work?
Can you take a look to my code? Two days trying to implement dependent dropdown (Also tried library by Victor)
public function repair_order() { $this->load->library('grocery_CRUD'); // dd $this->load->library('ajax_grocery_CRUD'); //$crud = new grocery_CRUD(); // dd $crud = new ajax_grocery_CRUD(); $crud->set_table('repair_order'); // Relation $crud->set_relation('client_id', 'client', 'full_name'); $crud->set_relation('device_id', 'device', 'model'); // dd $crud->set_relation_dependency('device_id','client_id','device.client_id'); $output = $crud->render(); $this->_listRepairOrder($output); }
These are my tables:
The funcionality I want to achieve is to show devices (2nd dropdown) owned by user selected in 1st dropdown
Thanks in advance :wub:
Posted 03 August 2016 - 06:51 AM
Hi
I am using ci bootstrap admin with modular structure. and want to integrate the dependent select extension but when i do so it sends me error
[HTTP/1.1 404 Not Found ] in response.
i am using
Grocery Crud @version 1.5.2
Codeigniter @version 3.0.2
Can anyone help me out
Thanks in advance
Posted 14 August 2016 - 06:19 AM
Thanks for your extension.
I receive this message:
A PHP Error was encounteredSeverity: Compile Error
Message: Access level to ajax_grocery_CRUD::$state_code must be protected (as in class Grocery_CRUD) or weaker
Filename: libraries/ajax_grocery_crud.php
Line Number: 255
Backtrace:
Please check
Posted 28 August 2016 - 15:11 PM
this code and library is not working.. I tried all versions of this libarary. after all efforts i was only successful to populate second drop down with only one sub-cateogry while there were about 6 records in actual in sub-category table.
I used other library for same function Gc_dependent_select.php it worked but for only one set of dependent drops down not for second.
my first one was category and sub-cateogry
other was option_grp and options
options_grp, options dependent drop down didnt work when cateogry sub category code was there when i removed subcategory and category code then options option_grp code works.
Posted 06 September 2016 - 12:10 PM
hello. im very newbie in grocery crud.
and now, i've tried to implement this library to my application. but, its not work very well. i can select subcategory from another category that dont have dependencies each other. and also, i've changed the jquery to newest vers. Whats the meaning of this?
thx a lot.
Posted 19 September 2016 - 15:18 PM
I just would like to add that I am using something like this as my $config ... The initial example works with Windows where filename is in-case-sensitive, and also where you removed the 'index.php' from your config.php. In cases where you are on Linux server and you are still using index.php in your URL, something like this may be better. Just sharing...
$config2 = array(
'main_table' => 'user_profiles','main_table_primary' => 'id',"url" => site_url( strtolower( __CLASS__ ) . '/' . __FUNCTION__ ) . '/', //path to method'segment_name' => 'a' // It's an optional parameter. by default "get_items");
See the site_url() ... I use that instead of base_url. I added strtolower for __CLASS__
I hope you find this useful.
Posted 01 September 2017 - 09:09 AM
There is no problem in this while inserting but when I press edit
Posted 01 September 2017 - 09:12 AM
There is no problem in this while inserting but when I press edit
Posted 18 September 2017 - 06:30 AM
It is working while inserting , but when I press the edit button, the dropdown 'state' is not fetching the value as I have shown in the above screen shot , Can anyone help me with that....?
Posted 22 September 2017 - 08:44 AM
Hi to all, and thanks for the grat job!!!
I have little problem with this extension,....
when i click on second dropbox in my console I have this error
jquery-1.11.1.min.js:4 POST http://localhost/orCI/ajax_extension/Te_idTutorEsterno/Te_idEnteErogatore/1 404 (Not Found)
My code is
$crud->set_relation('p_idscuola','istituti','Istituti_Intestazione', $whereIST) ->set_relation('Te_idTutorEsterno','tutoresterno','TE_Nome') ->set_relation('Te_idEnteErogatore','enteerogatore','EnteErogatore_Descrizione') ->set_relation('p_idAnnoScolastico','annoscolastico','AnnoScolastico' , $whereAS); $crud->set_relation_dependency('Te_idTutorEsterno','Te_idEnteErogatore','Te_idEnteErogatore');
the result is that not work....
Someone Can you help me ?
Thanks in advance
Posted 17 November 2017 - 10:35 AM
Can anyone help me with the where clause in set_relation_dependency() ?
-Thank You
Posted 18 November 2017 - 11:21 AM
well my friend - u have every where clause possible in set_relation.. now why all of a sudden u need a where clause in set_relation_dependancy?
Posted 09 February 2018 - 12:20 PM
Hi all,
First of all thanks the GC guys for this magnific piece of software. I love it's simplicity and neatness.
I'd like to share with you a short extension I built to allow dependant dropboxes to be declared easily and in the same fashion that we declare the grocery CRUD model:
Dependant drop downs:
Say we have an address table that has both country and state fields and we want to enforce that the state dropdown only shows states from the selected country.
Using the ajax_grocery_CRUD.php library (copy the attached file ajax_grocery_crud.php to the application\libraries folder), we would be writting the following php code:
function addresses_management() { $this->load->library('grocery_CRUD'); $this->load->library('ajax_grocery_CRUD'); //create ajax_grocery_CRUD instead of grocery_CRUD. This extends the functionality with the set_relation_dependency method keeping all original functionality as well $crud = new ajax_grocery_CRUD(); //this is the default grocery CRUD model declaration $crud->set_table('address'); $crud->set_relation('ad_country_id','country','c_name'); $crud->set_relation('ad_state_id','state','s_name'); //this is the specific line that specifies the relation. // 'ad_state_id' is the field (drop down) that depends on the field 'ad_country_id' (also drop down). // 's_country_id' is the foreign key field on the state table that specifies state's country $crud->set_relation_dependency('ad_state_id','ad_country_id','s_country_id'); $output = $crud->render(); $this->_example_output($output); }The SQL table definition for this example would be:
CREATE TABLE country ( c_id INT PRIMARY KEY, c_name VARCHAR(50) ); CREATE TABLE state ( s_id INT PRIMARY KEY, s_name VARCHAR(50), s_country_id INT, FOREIGN KEY (`s_country_id`) REFERENCES `country` (`c_id`) ); CREATE TABLE address ( ad_id INT PRIMARY KEY, ad_country_id INT, ad_state_id INT, FOREIGN KEY (`ad_country_id`) REFERENCES `country` (`c_id`), FOREIGN KEY (`ad_state_id`) REFERENCES `state` (`s_id`) );Dependant date filtering:
The source filed that provides the value to filter the dependent field can also be a date. I use it for of an agenda where I have a large set of 'performances' (musical shows) which I want to select on another table ('highlights') based on an input date.function highlights_management() { $crud = new ajax_grocery_CRUD(); $crud->set_table('highlight'); $crud->columns('date','performance_id'); $crud->set_relation('performance_id','performance','name'); $crud->set_relation('image_id','image','name','category_id IN (2,3,4)'); //'eventDate' is the field on the performance table that indicates the date of the performance // The drop down will list only the performances that happen on the selected date $crud->set_relation_dependency('performance_id','date','eventDate'); $output = $crud->render(); $this->_example_output($output); }Table highlights has both date (date) and performance_id (foreign key for performance table) fields.
Table performance table has a date field that is used to filter the performances to show on the dropdown.
I hope this may be useful for anyone else.
Keep up the good work GC people!
Hi ricardomduarte,
There is a clarification, the second dependent dropdown is not refreshed when the first dropdown is changed.... any idea?