eduardosuruagy Posted May 16, 2017 Share Posted May 16, 2017 I wanted this method as it was made to jump from the line in line and jump from column to column and when it reached the last column jumped to the next line, understood? function reconfigure(sender, store, columns, oldStore, the, eOpts) { var grid = sender; for (var i = 0; i < columns.length; i++) { if (columns.getEditor()) { columns.getEditor().on('specialkey', function(field, e) { if (e.getKey() == 13) { var store = grid.getStore(); var selModel = grid.getSelectionModel(); var selectedRecord = selModel.getLastSelected(); var recordIndex = store.indexOf(selectedRecord); var nextRecord = store.getAt(recordIndex + 1); if (nextRecord) { selModel.select(nextRecord); if (grid.editingPlugin && grid.uniRow && grid.uniCol){ var _row = grid.uniRow; var _col = grid.uniCol; setTimeout(function(){ grid.editingPlugin.startEdit(_row, _col); }, 10); } } } }) } } } Link to comment Share on other sites More sharing options...
Sherzod Posted May 16, 2017 Share Posted May 16, 2017 It seems yes, And what about this approach ?!: http://forums.unigui.com/index.php?/topic/4333-unidbgrid-and-enter-key/&do=findComment&comment=22039 Link to comment Share on other sites More sharing options...
eduardosuruagy Posted May 16, 2017 Share Posted May 16, 2017 This is similar to the other when it goes to the next field it is already in the editing state. Do a test on a grid with no record and try to include a new record using this function you showed, see that when it arrives in the last column it does nothing, neither the tab nor the enter work... Link to comment Share on other sites More sharing options...
Sherzod Posted May 16, 2017 Share Posted May 16, 2017 Hi Eduardo, Thank you! Yes, it can be done,By the way, you can make a test case, and give us a download linkWe will try to analyze it and find a solution. Best regards, Ok I will try... Link to comment Share on other sites More sharing options...
eduardosuruagy Posted May 16, 2017 Share Posted May 16, 2017 OK thank you!! Link to comment Share on other sites More sharing options...
eduardosuruagy Posted May 19, 2017 Share Posted May 19, 2017 Ok I will try... Can you see anything? Link to comment Share on other sites More sharing options...
Sherzod Posted May 19, 2017 Share Posted May 19, 2017 Hi, Can you try this ?! If this is normal for you, we will optimize the code: function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { var grid = sender; for (var i = 0; i < columns.length; i++) { if (columns[i].getEditor()) { columns[i].getEditor().on('specialkey', function(field, e) { if (e.getKey() == 13) { var store = grid.getStore(); var selModel = grid.getSelectionModel(); var selectedRecord = selModel.getLastSelected(); var recordIndex = store.indexOf(selectedRecord); if (columns[grid.uniCol].isLastVisible) { var nextRecord = store.getAt(recordIndex + 1); if (nextRecord) { selModel.select(nextRecord); }; }; if (grid.editingPlugin && grid.uniRow && grid.uniCol) { var _row = grid.uniRow; var _col; if (!columns[grid.uniCol].isLastVisible) { _col = grid.uniCol + 1 } else { _col = 1; // first editable column index }; setTimeout(function() { grid.editingPlugin.startEdit(_row, _col); }, 10); }; } }) } } } Best regards, Link to comment Share on other sites More sharing options...
eduardosuruagy Posted May 19, 2017 Share Posted May 19, 2017 If I am editing the first line of the grid it does nothing, I give enter but nothing happens. If it's the second line it edits and jumps to the next field. When I am in the last field and press enter it jumps down the line being that it is in the last column, it should go to the first column. Link to comment Share on other sites More sharing options...
Sherzod Posted May 19, 2017 Share Posted May 19, 2017 Can you make a simple testcase for this please ?! Link to comment Share on other sites More sharing options...
eduardosuruagy Posted May 19, 2017 Share Posted May 19, 2017 How do I add an attachment? Link to comment Share on other sites More sharing options...
eduardosuruagy Posted May 19, 2017 Share Posted May 19, 2017 The following example Link to comment Share on other sites More sharing options...
eduardosuruagy Posted May 19, 2017 Share Posted May 19, 2017 The following example Grid - DbGrid Editavel.rar Link to comment Share on other sites More sharing options...
Sherzod Posted May 19, 2017 Share Posted May 19, 2017 Ok thanks for the testcase, I will analyze Link to comment Share on other sites More sharing options...
Sherzod Posted May 20, 2017 Share Posted May 20, 2017 Hi, Can you try this approach ?!: function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { var grid = sender; function fn() { var selModel = grid.getSelectionModel(); var _row = selModel.getCurrentPosition().row; var _col = selModel.getCurrentPosition().column; if (grid.columnManager.columns[_col].isLastVisible) { _col = 0; _row += 1; } else { _col += 1; }; setTimeout(function() { grid.getSelectionModel().select({ row: _row, column: _col }); grid.editingPlugin.startEdit(_row, _col); }, 10); }; for (var i = 0; i < columns.length; i++) { var hasEditor = columns[i].getEditor(); var ed = hasEditor || columns[i]; if (columns[i].checkColumn) { columns[i].on('keydown', function(a, b, c, d, e) { if (e.getKey() == 13) { fn(); } }) } else if (columns[i].rdonly) { ed.on('keydown', function(a, b, c, d, e) { if (e.getKey() == 13) { fn() } }) } else { ed.on('specialkey', function(field, e) { if (e.getKey() == 13) { fn(); } }) } } } Best regards, Link to comment Share on other sites More sharing options...
eduardosuruagy Posted May 22, 2017 Share Posted May 22, 2017 It worked perfect, congratulations for the great work of you, that's why I bought the tool, besides being great, also has a great support. Thank you!! Link to comment Share on other sites More sharing options...
eduardosuruagy Posted May 22, 2017 Share Posted May 22, 2017 Hi, Can you try this approach ?!: function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { var grid = sender; function fn() { var selModel = grid.getSelectionModel(); var _row = selModel.getCurrentPosition().row; var _col = selModel.getCurrentPosition().column; if (grid.columnManager.columns[_col].isLastVisible) { _col = 0; _row += 1; } else { _col += 1; }; setTimeout(function() { grid.getSelectionModel().select({ row: _row, column: _col }); grid.editingPlugin.startEdit(_row, _col); }, 10); }; for (var i = 0; i < columns.length; i++) { var hasEditor = columns[i].getEditor(); var ed = hasEditor || columns[i]; if (columns[i].checkColumn) { columns[i].on('keydown', function(a, b, c, d, e) { if (e.getKey() == 13) { fn(); } }) } else if (columns[i].rdonly) { ed.on('keydown', function(a, b, c, d, e) { if (e.getKey() == 13) { fn() } }) } else { ed.on('specialkey', function(field, e) { if (e.getKey() == 13) { fn(); } }) } } } Best regards, It worked perfect, congratulations for the great work of you, that's why I bought the tool, besides being great, also has a great support. Thank you!! Link to comment Share on other sites More sharing options...
eduardosuruagy Posted May 22, 2017 Share Posted May 22, 2017 I'm sending another example so you can see what happens. When you edit the Address column onwards, it says exactly what you did, but when it arrives in the Cep column and gives an Enter, even without making any changes to the registry, the system cancels the changes that were made in the previous columns. Another problem I noticed was when I am in the last line and in the last field and I click on enter and the system does not execute any view of ClientDataSet. When I'm in the last column I give the enter in the ClientDataSet in the AfterPost event I give an ApplyUpdates (0). Grid - DbGrid Editavel.rar Link to comment Share on other sites More sharing options...
Sherzod Posted May 24, 2017 Share Posted May 24, 2017 Hi, I'm sending another example so you can see what happens. When you edit the Address column onwards, it says exactly what you did, but when it arrives in the Cep column and gives an Enter, even without making any changes to the registry, the system cancels the changes that were made in the previous columns. Yes, because your value in "Cep column" is incorrect. You can try to use this approach for this issue: function canceledit(editor, context, eOpts) { if (context.originalValue === context.value) { return false }; } Best regards, Link to comment Share on other sites More sharing options...
Gregue Posted October 13, 2017 Share Posted October 13, 2017 How to use this function in Grid with GroupHeader? Show error: columns.getEditor is not a function function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { var grid = sender; for (var i = 0; i < columns.length; i++) { if (columns.getEditor()) { columns.getEditor().on('specialkey', function(field, e) { if (e.getKey() == 13) { var store = grid.getStore(); var selModel = grid.getSelectionModel(); var selectedRecord = selModel.getLastSelected(); var recordIndex = store.indexOf(selectedRecord); var nextRecord = store.getAt(recordIndex + 1); if (nextRecord) { selModel.select(nextRecord); if (grid.editingPlugin && grid.uniRow && grid.uniCol){ var _row = grid.uniRow; var _col = grid.uniCol; setTimeout(function(){ grid.editingPlugin.startEdit(_row, _col); }, 10); } } } }) } } } How to use this function in Grid with GroupHeader? Show error Link to comment Share on other sites More sharing options...
Sherzod Posted October 14, 2017 Share Posted October 14, 2017 Hi, Which edition and build are you using ? Best regards, Link to comment Share on other sites More sharing options...
Gregue Posted October 15, 2017 Share Posted October 15, 2017 Hi, thanks for the reply, Delphi 10.1 Berlin + UniGUI 1.0 trial if I remove groupheader, works perfectly. Link to comment Share on other sites More sharing options...
alesf76 Posted January 23, 2018 Share Posted January 23, 2018 Hi, Then try: function reconfigure(sender, store, columns, oldStore, the, eOpts) { var grid = sender; for (var i = 0; i < columns.length; i++) { if (columns[i].getEditor()) { columns[i].getEditor().on('specialkey', function(field, e) { if (e.getKey() == 13) { var store = grid.getStore(); var selModel = grid.getSelectionModel(); var selectedRecord = selModel.getLastSelected(); var recordIndex = store.indexOf(selectedRecord); var nextRecord = store.getAt(recordIndex + 1); if (nextRecord) { selModel.select(nextRecord); } } }) } } } Best regards. Where this javascript have to be put ? Link to comment Share on other sites More sharing options...
Sherzod Posted January 24, 2018 Share Posted January 24, 2018 UniDBGrid1 -> ClientEvents -> ExtEvents -> function reconfigure Link to comment Share on other sites More sharing options...
Stemon63 Posted January 24, 2018 Share Posted January 24, 2018 Hi, and now, with ExtJs 6.5?All works,or it must be change ??Thanks, Stefano Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now