EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: jaimi on November 18, 2014, 02:53:42 AM



Title: depending combobox within a edatagrid
Post by: jaimi on November 18, 2014, 02:53:42 AM
Hi, I have defined a combobox within a edatagrid like this:
 ,{field   :'GLL_GER'
      ,title   :'Land'
      ,width   :200
      ,sortable:'true'
      ,editor  : {
        type   :'combobox'
      ,options:{
         valueField:'OLT00L001T_KEY'
        ,textField:'GLL_GER'
       ,url:'ueln.act.php?frm=BRE&act=L&lkp=GLL'
       ,required:true
      }
     }
   }   

How can I create another combobox dependig on the first, so that the url of the second would like this:
...
,url:'ueln.act.php?frm=BRE&act=L&lkp=ZUG&key=' + OLT00L001T_KEY
...

Thanks, Jaimi


Title: Re: depending combobox within a edatagrid
Post by: stworthy on November 18, 2014, 07:54:49 AM
When a row begins to be edited, the 'onBeginEdit' event fires. You can get the current editors and create a dependency between these editors.
Code:
$('#dg').datagrid({
onBeginEdit:function(index,row){
var c1 = $(this).datagrid('getEditor',{index:index,field:'GLL_GER1'});
var c2 = $(this).datagrid('getEditor',{index:index,field:'GLL_GER2'});
var v1 = $(c1.target).combobox('getValue');
$(c1.target).combobox({
url: ...,
value: v1,
onChange: function(value){
var url = 'ueln.act.php?frm=BRE&act=L&lkp=ZUG&key=' + value;
$(c2.target).combobox('reload',url);
}
});
}
})


Title: Re: depending combobox within a edatagrid
Post by: jaimi on November 27, 2014, 12:36:22 AM
it's cool, thx. Jaimi