EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Alfred on May 04, 2017, 04:31:21 AM



Title: Cannot save combogrid editor
Post by: Alfred on May 04, 2017, 04:31:21 AM
When I hit the save button
Code:
<a href="#" class="easyui-linkbutton" iconCls="icon-save" onclick="javascript:$('#saldgg').edatagrid('saveRow')">Save</a>
, no update can occur. What could be the problem?


Code:
<th field="batchNum" sortable="true" width="80" editor="{type:'combogrid',
                                    options:{
                                        panelWidth: 500,
                                        idField:'id',
                                        textField:'drugName',
                                        url:'views/getbatch.php',
                                        mode:'remote',
                                        fitColumns:'true',
                                        columns:[[
                                                {field:'id',title:'Id',width:40},
                                                {field:'drugName',title:'Drug Name',width:100},
                                                {field:'batchNum',title:'Batch',width:60},
                                                {field:'unit',title:'Unit',width:60},
                                                {field:'retailPrice',title:'Price',width:60},
                                                {field:'expDate',title:'Expiry',width:60}
                                        ]],                                                                   
                                    onChange:function(value){
                                            var g = $(this).combogrid('grid');
                                            g.datagrid('load',{
                                                q:value
                                            });
                                            var tr = $(this).closest('tr.datagrid-row');
                                            var idx = parseInt(tr.attr('datagrid-row-index'));
                                            var bt = $('#saldgg').edatagrid('getEditor', {index:idx, field:'batchNum'});
                                            var dr = $('#saldgg').edatagrid('getEditor', {index:idx, field:'particular'});
                                            var ed = $('#saldgg').edatagrid('getEditor', {index:idx, field:'retailPrice'});
                                            var zz = $('#saldgg').edatagrid('getEditor', {index:idx, field:'qntOrdered'});
                                            var zs = $('#saldgg').edatagrid('getEditor', {index:idx, field:'unit'});
                                            var r;                                       
                                            var cgrid = ($(this).combogrid('grid'));
                                            r = cgrid.datagrid('getSelected');  // get the selected row                                           
                                            $(dr.target).textbox('setValue', r.drugName);
                                            $(bt.target).textbox('setValue', r.batchNum);
                                            $(ed.target).textbox('setValue', r.retailPrice);
                                            $(zz.target).textbox('setValue', 1);
                                            $(zs.target).textbox('setValue', r.unit);
                                           
                                    }
                                   
                               }
                            }">Batch</th>


Title: Re: Cannot save combogrid editor
Post by: jarry on May 04, 2017, 07:02:21 PM
To save the row data to remote server, you have to set the 'saveUrl' and 'updateUrl' properties. Please look at this tutorial https://www.jeasyui.com/tutorial/app/crud2.php