jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Dependency dropdown list
Tagged: angular grid, bootstrap grid, dependency dropdown in grid, javascript grid, jquery grid, jqwidgets grid, jqxgrid
This topic contains 7 replies, has 2 voices, and was last updated by Hristo 9 years, 2 months ago.
-
AuthorDependency dropdown list Posts
-
Hi,
I have the tried the following code to get the dependency dropdown in grid.
But second dropdown id not getting the values. Please help.{ text: 'Account', datafield: 'account',columntype: 'dropdownlist', createeditor: function (row, column, editor) { // assign a new data source to the dropdownlist. editor.jqxDropDownList({ autoDropDownHeight: true, source: accountnames }); }, // update the editor's value before saving it. cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { // return the old value, if the new value is empty. if (newvalue == "") return oldvalue; }, width: "7%",cellclassname: "columncolorEdit", cellsrenderer: renderer }, { text: 'Group', datafield: 'group1', columntype: 'dropdownlist', initeditor: function (row, column, editor) { // assign a new data source to the combobox. var accountName= $('#jqxgrid').jqxGrid('getcellvalue', row, "account"); //alert(accountName); if(accountName){ $.ajax({ url:'getGroups.php?account='+accountName, type:"GET", success:function(data){ alert(data); var groupnames=data;// I'm getting the required data here in array. But next is the problem. editor.jqxDropDownList({ autoDropDownHeight: true, source: groupnames }); } }); } }, // update the editor's value before saving it. cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { // return the old value, if the new value is empty. if (newvalue == "") return oldvalue; }, width: "9%",cellclassname: "columncolorEdit", cellsrenderer: renderer }
Hello Kiran,
In second DropDownList (column ‘Group’) you miss to set “createeditor” in that column.
If correctly guess from this part of code you try to set some custom items for the dropdownlist.
Please take a look those demos:
http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/customizededitors.htm?arctic
http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/cellcustomediting.htm?arctic
Or maybe you try to create something like this:
http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/cascadingediting.htm?arcticBest Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comHello Hristo,
I checked all the links provided by you. Thanks.
However, I’m trying dependency dropdown with dynamic data source using ajax.data=['Gp1','Gp2','Gp3','Gp4','Gp5'] // reply from ajax request.
In my above code, if I replace there
groupname=data;
with
groupname=['Gp1','Gp2','Gp3','Gp4','Gp5'];
it works awesome.
Then, why we need to hard code the array, instead of directly assigning
groupname=data
?
and why I need to use “createeditor” while using “initeditor” ?Please help.
Thanks,
KiranHello Kiran,
Is there some error message in the console?
createeditor is called once. initeditor is called each time an editor is opened.
In the last demo – Cascading ComboBoxes, when make some changes second widget (combobox – shows message “Select a city…” when make some changes in first) otherwise the cell is empty and looks wrong.Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comHi Hristo,
I’m not getting error message in console. In debug mode (firebug), the variable
groupname
is getting the expected value.
editor.jqxDropDownList({ autoDropDownHeight: true, source: groupnames });
even here also. But after this if I continue, the dropdown will be empty asPlease Choose..
. unable to understand where I’m failing. I tried to moveeditor.jqxDropDownList({ autoDropDownHeight: true, source: groupnames });
outside the ajax braces and makinggroupname
as global variable. But it same issue.Can you please create any example without switch case and using JSON binding data for DD.
Thanks,
KiranHello Kiran,
Try to change settings in “ajax” async: false (default: true).
We have demo – the DropDownList is bound to JSON data.
http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxdropdownlist/bindingtojson.htm?arcticBest Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comHi Hristo,
Its not working.
Thanks,
KiranHello Kiran,
Could you give more information? What exactly not work?
Are there any error messages?
And if it possible could share Your code with all data.
(better in https://www.jseditor.io/)Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.