EasyUI Forum
May 16, 2024, 06:40:21 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: datagrid combobox field onChange  (Read 8106 times)
zombie86
Newbie
*
Posts: 24


View Profile WWW Email
« on: January 13, 2019, 12:04:47 AM »

Dear EasyUI Team,

am defining combobox editor and textbox editor as follow:
<th style="width:15%;" data-options="field:'material_id',
                                formatter:function(value,row){
                                    return row.material_name;
                                },
                                editor:{
                                    type:'combobox',
                                    options:{
                                        data:accounts.material_dropdown,
                                        method:'get',
                                        valueField:'id',
                                        textField:'text',
                                        required:true,
                                        onChange:function(value){
                                            var row = $('#dg_quotation_trans').datagrid('getSelected');
                                            var rowIndex = $('#dg_quotation_trans').datagrid('getRowIndex', row);
                                            var ed_material_id = $('#dg_quotation_trans').datagrid('getEditor',{index:rowIndex,field:'material_id'});
                                            var ed_old_material_id = $('#dg_quotation_trans').datagrid('getEditor',{index:rowIndex,field:'old_material_id'});
                                            var ed_material_type_id = $('#dg_quotation_trans').datagrid('getEditor',{index:rowIndex,field:'material_type_id'});
                                            var ed_sale_uom = $('#dg_quotation_trans').datagrid('getEditor',{index:rowIndex,field:'sale_uom'});
                                            var ed_sales_tax_id = $('#dg_quotation_trans').datagrid('getEditor',{index:rowIndex,field:'sales_tax_id'});
                                            var ed_tax_value = $('#dg_quotation_trans').datagrid('getEditor',{index:rowIndex,field:'tax_value'});
                                            var ed_tax_percent = $('#dg_quotation_trans').datagrid('getEditor',{index:rowIndex,field:'sales_tax_percent'});
                                            alert($(ed_old_material_id.target).textbox('getValue'));
                                            $.ajax({
                                                url:'<?php echo base_url('pediaerp/wim/materials/ajax_get_material_details/')?>'+value,
                                                type:'GET',
                                                dataType:'JSON',
                                                success:function(data){
                                                    if(data){
                                                        $(ed_sale_uom.target).textbox('setValue',data.sale_abbreviation);
                                                        $(ed_material_type_id.target).textbox('setValue',data.material_type_id);
                                                        if(is_taxable==1){
                                                            $(ed_sales_tax_id.target).combobox('setValue',data.sale_sales_tax_id);
                                                        }else{
                                                            $(ed_sales_tax_id.target).combobox('disable');
                                                            $(ed_tax_value.target).numberbox('setValue',0.000);
                                                            $(ed_tax_percent.target).numberbox('setValue',0.000);
                                                        }
                                                        get_bulk_price();
                                                    }
                                                }
                                            });
                                        }
                                    }
                                }">Material Name</th>
                        <th style="width:5%;" data-options="field:'old_material_id',align:'center',hidden:'true',editor:{type:'textbox'}"></th>

and once am entering edit mode the alert displays no value for old_material_id which already has a value from json

so would you please help me on this??

am stuck here....
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: January 13, 2019, 11:44:00 PM »

You should initialize the 'value' property to prevent from triggering the 'onChange' event when entering the editing mode. Please refer to the code below:
Code:
$('#dg').datagrid({
onBeforeEdit: function(index,row){
var col = $(this).datagrid('getColumnOption', 'productid');
col.editor = {
type:'combobox',
options:{
valueField:'productid',
textField:'productname',
method:'get',
url:'products.json',
required:true,
value: row.productid,
onChange: function(value){
var dg = $('#dg');
var row = dg.datagrid('getSelected');
var rowIndex = dg.datagrid('getRowIndex', row);
var ed = dg.datagrid('getEditor', {index:rowIndex,field:'attr1'});
var text = $(ed.target).textbox('getValue');
alert(text)
}
}
}
}
})
Logged
zombie86
Newbie
*
Posts: 24


View Profile WWW Email
« Reply #2 on: January 14, 2019, 06:45:55 AM »

Dear Stworthy,

thanks for your kind help, seems its working properly now

thanks again and again Smiley
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!