Hi,
Is it possible to make 3 columns dropdown dependent,so when I modify 1 the other 2 modify. I have tried like this: " $col["editoptions"] = array("value"=>$str ,
"onchange" => array("sql"=>"select a.id as k, b.title1 as v from as a left join aso b on b.id=a.aso_id where a.cat_id={cat_id} group by v",
"update_field" => "asociericulinare"),
"onchange" => array("sql"=>"select a.id as k, b.title2 as v from as a left join complex b on b.id=a.comp_Id where a.cat_id={cat_id} group by v",
"update_field" => "complexitate_id")
); "
Is this possible?
Yes, thats doable.
If you are using v1.5.2, you can check
demos/appearence/dropdown-callback.php
1) define callback js function
$col["editoptions"] = array(
"value"=>$str,
"onchange" => array(
"sql"=>"select * from clients",
"search_on"=>"client_id",
"callback" => "fill_form" )
);
2) set onload-sql for dropdowns
$col["editoptions"]["onload"]["sql"] = "select note as k, note as v from invheader WHERE client_id = '{name}'";
$col["editoptions"]["onload"]["sql"] = "select amount as k, amount as v from invheader WHERE client_id = '{name}'";
3) Define callback function:
<script>
function fill_form(data)
{
// fill dropdown 1 based on row data
o = jQuery('select[name=note]').get();
o.event = 'onload'; fx_get_dropdown(o,'note');
// fill dropdown 2 based on row data
o = jQuery('select[name=amount]').get();
o.event = 'onload'; fx_get_dropdown(o,'amount');
}
I have tried your example and it doesn't work, and to be clear I was referring to the filter dropdown. I have 3 columns, and the first one needs
to influente the other 2. So if for example I choose an element in the first drop down that has the id '1' I want the other ones to filter according to
this is. It is like dropdown dependence but instead of one column to be dependent I want 2.
here is the error message:"Uncaught Error: Syntax error, unrecognized expression: select[name=].editable "
Please email me the code along with database sql sample.
I'll review and try to reply back with working code.
You can email me at [email protected]
Hi Abu,
I have the same problem here. I want that all the search/filter dropdowns to be dynamically populated based on the selection made on the previous one.
Let say that we have 4 columns. If I filter the first one using a dropdown as a search/filter method, I want that the second, third and fourth search/filter dropdown to have only the remaining info as search/filter options, not all the initial options. Also I want that this filters to independent, not dependent. Because I don't know exactly what I want to filter first. I could filter the table starting with the fourth column and then with the second one, and so on.
As I can see, the provided example is more hopeful when you are editing a row/entry. But I can't make it work for the column filtering action.
Hello All,
I've added this function in lib.
Demo is available here: http://www.phpgrid.org/demo/demos/appearence/dropdown-dependent-2.php
Please contact on email ([email protected]) with your ORDER NO. to get latest build / demo.
Hi Abu,
Thanks for you reply !
I see that you are updating 2 dropdowns based on the first one selection. But if I go further and I filter the second column (Invoices) after "note 1", the third dropdown (Amount) should have only one option (100.00) to select (in this case, or more in other cases).
Also I have noticed that if I filter the table starting with the second column (Invoices), the other 2 dropdowns aren't updated with the remaining options.
As I said, I want that all dropdown options to be automatically/dynamically updated based on what results I have in their columns after a filter was applied in other column. I don't know in which order the table will be filtered and also I don't know exactly the number of columns (I could have 4 columns or 20 columns). Is this doable ?
Thanks again for your support !
Hello,
We have functionality like …
1) Single dependent dropdown
d1 can change results of d2.
d2 can change results of d3.
and so on.
2) Multiple dependent dropdown
d1 can change d2,d3,d4
d2 can change d5,d6
Now for 'automatically/dynamically updated' options, it is currently not supported.
if you can send the database dump and exact scenario, i can try to make it.
Hi !
I think that the second option with multiple dependent dropdown could help me for the moment. I'll send you an email with my ORDER NO. so you can send me the latest build.
Regarding to my request for dynamically updated options, my database or the scenario are irrelevant. You could try to make it work on your database info. I need to filter the table starting with what column I want and after that, all the dropdowns options to be updated with the remaining info in their columns. Also when I apply the second filter, all dropdown options need to be updated again, and so on. The last filter always need to update the other ones, no mater how many they are.
Please let me know when you have a solution for this request.
I don't know why, but I don't get email notifications when you are posting on this thread. Can you also fix this. Thank you !
Hello Andrei,
I've emailed you the update.
This looks doable but it will need some time to prepare demo / db.
Currently tagging it in todos.
Hi,
I have receive it.
Great news ! This will be a great feature ! Please can let me know when it's done so I can use it ?
Thank you again for your support.
You can follow twitter / google+ accounts.
Updates are published on these channels.
Hi Abu,
Is it possible to make only the search toolbar dependent to another column but on edit to have all the values?
Hello,
Currently it is not doable. The dropdown function comes with limited customization.
As an alternate, you can have another extra column, with same column name.
You can make this new column hidden in listing.
$col["show"]["list"] = false;
And make the actual column hidden in edit mode.
$col["show"]["edit"] = false;
Now with new column, don't set $col["editoptions"]["onload"]["sql"]. Just set:
$str = $g->get_dropdown_values("select amount as k, amount as v from invheader");
$col["editoptions"] = array("value"=>":;".$str);
By this way, it will always show all options in edit mode.