jQWidgets Forums

jQuery UI Widgets Forums Grid Dependency dropdown list

This topic contains 7 replies, has 2 voices, and was last updated by  Hristo 9 years, 2 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • Dependency dropdown list #81769

    Kiran
    Participant

    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 
                          }
    Dependency dropdown list #81781

    Hristo
    Participant

    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?arctic

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

    Dependency dropdown list #81831

    Kiran
    Participant

    Hello 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,
    Kiran

    Dependency dropdown list #81902

    Hristo
    Participant

    Hello 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 Hristov

    jQWidgets team
    http://www.jqwidgets.com

    Dependency dropdown list #81918

    Kiran
    Participant

    Hi 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 as Please Choose... unable to understand where I’m failing. I tried to move editor.jqxDropDownList({ autoDropDownHeight: true, source: groupnames }); outside the ajax braces and making groupname as global variable. But it same issue.

    Can you please create any example without switch case and using JSON binding data for DD.

    Thanks,
    Kiran

    Dependency dropdown list #81945

    Hristo
    Participant

    Hello 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?arctic

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

    Dependency dropdown list #82104

    Kiran
    Participant

    Hi Hristo,

    Its not working.

    Thanks,
    Kiran

    Dependency dropdown list #82154

    Hristo
    Participant

    Hello 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 Hristov

    jQWidgets team
    http://www.jqwidgets.com

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.