Title: Save data on Edatagrid on enter key press. Post by: Alfred on March 10, 2017, 08:42:17 AM I have the following code for my edatagrid. And it works fine. But I need a feature: save data on hitting Enter Key.
Quote $('#dg').edatagrid({ url: 'get_customer.php', saveUrl: '../controller/save_customer.php', updateUrl: '../controller/update_customer.php', destroyUrl: '../controller/destroy_customer.php' }); Title: Re: Save data on Edatagrid on enter key press. Post by: Alfred on March 10, 2017, 09:20:52 AM This code works fine. But I want reload the datagrid and add new row. Is that possible and How?
Quote onBeginEdit: function(index,row){ var dg = $(this); var editors = dg.edatagrid('getEditors',index); for(var i=0; i<editors.length; i++){ $(editors.target).textbox('textbox').bind('keydown',function(e){ if (e.keyCode == 13){ dg.edatagrid('endEdit', index); // if (index<dg.edatagrid('getRows').length-1){ // dg.edatagrid('selectRow', index+1).edatagrid('beginEdit', index+1); // } //$('#dg').edatagrid('reload'); $('#dg').edatagrid('addRow'); } }); } if (editors.length){ $(editors[0].target).textbox('textbox').focus(); } } Title: Re: Save data on Edatagrid on enter key press. Post by: stworthy on March 12, 2017, 07:53:51 AM What is the purpose of calling the 'reload' method? Once you call the 'saveRow' method, the editing data is updated to the row and saved to the server.
Title: Re: Save data on Edatagrid on enter key press. Post by: Alfred on March 15, 2017, 10:00:20 AM Yes I learnt that this is not necessary. It's only my assumption before I actually tested it. I added
Code: autoSave:true, |