EasyUI Forum

General Category => General Discussion => Topic started by: putusundika on August 08, 2012, 08:10:51 PM



Title: chain combo inline editor
Post by: putusundika on August 08, 2012, 08:10:51 PM
how can i make a chain combobox inline editing ? for common sample in datagrid : city | country.
city load database. but after selection on city, combobox on country will displaying only related item from city.
i've read combo-tree sample, but still dont know how to implement it to inline editor with separate column.

best regards
putu


Title: Re: chain combo inline editor
Post by: stworthy on August 09, 2012, 06:10:54 PM
It is similar with this tutorial http://www.jeasyui.com/tutorial/datagrid/datagrid15.php.
To solve your issue, define two column with 'combobox' editor: city and country. In the city combobox bind 'onChange' event, in which get the new city value and then reload the country combobox data. The code looks like this:

Code:
$('#dg').datagrid({
columns:[[
{field:'city',title:'City',width:100,
editor:{
type:'combobox',
options:{
onChange:function(value){
// get the country editor
var ed = $('#dg').datagrid('getEditor',{index:idx,field:'country'});
// reload its data
$(ed.target).combobox('reload','get_data.php?city='+value);
}
}
}
},
{field:'country',title:'Country',width:100,editor:{type:'combobox',options:{...}}}
]]
});


Title: Re: chain combo inline editor
Post by: putusundika on August 18, 2012, 05:46:10 AM
hii..
i'ved try this but not working.
inline edit, i have 2 column editor, partname (combobox) and quantity(numberbox).
quantity will show the last quantity of selected partname.
so, actualy it's not a editor. but i dont know how to do that. Thats why i try with editor (numberbox) .
but not working.

please help me, there must be something wrong in mycode below.

Code:
function tagData(){
var row = $('#dg').datagrid('getSelected');
var idd;
if (row){
 $('#dlgtag').dialog('open').dialog('setTitle','Set Supplier');
 $(function(){
   $('#dlgt').edatagrid({
   onEdit:function(index,row){ idd=index;},
   onAdd:function(index,row){idd=index;},
   url: 'get_data1.php?id='+row.idfbstockopname,
   columns:[[
   {field:'name_part',title:'Part Name',width:200,editor:{type:'combobox',options: 
     {url:'part.php',valueField:'id_part',textField:'name_part',required:true,
      onChange:function(value){
var ed = $('#dlgt').edatagrid('getEditor',{index:idd,field:'lastqty_fbstockopname_detil'});
$(ed.target).numberbox('setValue',value);},
}}},
        {field:'lastqty_fbstockopname_detil',title:'Quantity',align:'left',width:100,editor:{type:'numberbox',}
}}
]],
});
});}
    }


best regards


Title: Re: chain combo inline editor
Post by: stworthy on August 20, 2012, 02:07:01 AM
Please refer to this example: http://jsfiddle.net/Ynkyq/