sicoobcooplivre Posted February 7, 2023 Share Posted February 7, 2023 @SherzodPlease, is there a way to configure the dbgrid so that when the user is in the last column and he presses next, he remains on the same line? I want him to stay on the line he's on until he keys down, then yes, switch lines! Thanks! 1 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 7, 2023 Share Posted February 7, 2023 Hello, I will try to analyze. Quote Link to comment Share on other sites More sharing options...
sicoobcooplivre Posted February 7, 2023 Author Share Posted February 7, 2023 Thank you for your attention! Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 7, 2023 Share Posted February 7, 2023 1 hour ago, sicoobcooplivre said: and he presses next Can you please explain in more detail? Quote Link to comment Share on other sites More sharing options...
sicoobcooplivre Posted February 7, 2023 Author Share Posted February 7, 2023 I'm setting up a dbgrid for users to launch daily activities. Natively, if the user is in the last column and presses right, it will automatically go to the next record. The same happens if he is in the first column and he presses the left key, he automatically goes back a record. I want to lock it in the record, and only go to the next record if he presses down arrow, or go to the previous record if he presses up. Sorry I can't explain it right. Can you help? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 7, 2023 Share Posted February 7, 2023 I understood you. I will try to analyze. 1 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 8, 2023 Share Posted February 8, 2023 @sicoobcooplivre Test this approach: function cellkeydown(sender, td, cellIndex, record, tr, rowIndex, e, eOpts) { if (e.event.key == "ArrowRight") { currPos = sender.getOwnerGrid().getSelectionModel().getCurrentPosition(); if (sender.getOwnerGrid().getColumns()[currPos.column].isLastVisible == true) { sender.getOwnerGrid().getSelectionModel().setCurrentPosition({row: currPos.row, column: sender.getOwnerGrid().getVisibleColumnManager().getFirst().getIndex()}); sender.getOwnerGrid().getNavigationModel().setPosition(currPos.row, sender.getOwnerGrid().getVisibleColumnManager().getFirst().getIndex()); return false } } else if (e.event.key == "ArrowLeft") { currPos = sender.getOwnerGrid().getSelectionModel().getCurrentPosition(); if (sender.getOwnerGrid().getColumns()[currPos.column].isFirstVisible == true) { sender.getOwnerGrid().getSelectionModel().setCurrentPosition({row: currPos.row, column: sender.getOwnerGrid().getVisibleColumnManager().getLast().getIndex()}); sender.getOwnerGrid().getNavigationModel().setPosition(currPos.row, sender.getOwnerGrid().getVisibleColumnManager().getLast().getIndex()); return false } } } Quote Link to comment Share on other sites More sharing options...
sicoobcooplivre Posted February 8, 2023 Author Share Posted February 8, 2023 It worked out! Thank you very much! Quote Link to comment Share on other sites More sharing options...
sicoobcooplivre Posted February 8, 2023 Author Share Posted February 8, 2023 Taking advantage of this topic, I have one more doubt, please can you help: I'm using the RowWidget option in the Grid to display some registry sub-items. Is there a possibility that when the user clicks on the + (RowWidget) I collect all that are already open to keep open only the RowWidget of the record that he clicked on? Thanks! Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 8, 2023 Share Posted February 8, 2023 Didn't understand your question, sorry. Quote Link to comment Share on other sites More sharing options...
sicoobcooplivre Posted February 8, 2023 Author Share Posted February 8, 2023 Sorry, I was wrong, it's already working the way I need it! Thanks! Quote Link to comment Share on other sites More sharing options...
sicoobcooplivre Posted February 8, 2023 Author Share Posted February 8, 2023 One more doubt: in the form show, it would be possible to focus on a certain column of the grid, because I need that when the user enters the form, he already gives the direct focus on column 2. Thanks! Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 8, 2023 Share Posted February 8, 2023 1 hour ago, sicoobcooplivre said: One more doubt: in the form show, it would be possible to focus on a certain column of the grid, because I need that when the user enters the form, he already gives the direct focus on column 2. You can just use: procedure TMainForm.UniDBGrid1AfterLoad(Sender: TUniCustomDBGrid); begin (Sender as TUniDBGrid).CurrCol := 2; end; Quote Link to comment Share on other sites More sharing options...
sicoobcooplivre Posted February 9, 2023 Author Share Posted February 9, 2023 It worked out! Thank you very much! Quote Link to comment Share on other sites More sharing options...
sicoobcooplivre Posted February 13, 2023 Author Share Posted February 13, 2023 Please, is there a way to run the rowwidget of the selected record through a button outside the dbgrid? Thanks! Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 13, 2023 Share Posted February 13, 2023 1 minute ago, sicoobcooplivre said: Please, is there a way to run the rowwidget of the selected record through a button outside the dbgrid? ? Quote Link to comment Share on other sites More sharing options...
sicoobcooplivre Posted February 13, 2023 Author Share Posted February 13, 2023 I need to execute the + click (rowwidget) of the registry programmatically. I have an include item button, where I want to execute the + (rowwidget) from the button, so that the user can start typing the selected data. I just need to run the + (rowwidget) programmatically! Sorry I can't explain it right, I'm learning! Thank you for your attention! Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 13, 2023 Share Posted February 13, 2023 There are solutions on the forum, search by keyword - rowwidget. Quote Link to comment Share on other sites More sharing options...
sicoobcooplivre Posted February 13, 2023 Author Share Posted February 13, 2023 I searched but couldn't find it! Can you help me? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 14, 2023 Share Posted February 14, 2023 9 hours ago, sicoobcooplivre said: I need to execute the + click (rowwidget) of the registry programmatically. I have an include item button, where I want to execute the + (rowwidget) from the button, so that the user can start typing the selected data. I just need to run the + (rowwidget) programmatically! Try this approach. 1. UniDBGrid1.ClientEvents.ExtEvents -> function afterrender(sender, eOpts) { sender._toggleSelectedRow = function() { if (sender.getPlugin('rowWidget')) { sender.getPlugin('rowWidget').toggleRow( sender.getSelectionModel().getCurrentPosition().rowIdx, sender.getSelectionModel().getSelected().items[0] ) } } } 2. Usage -> procedure TMainForm.UniButton1Click(Sender: TObject); begin with UniDBGrid1.JSInterface do JSCall('_toggleSelectedRow', []) end; 8 hours ago, sicoobcooplivre said: I searched but couldn't find it! For example, there was this post: 1 Quote Link to comment Share on other sites More sharing options...
sicoobcooplivre Posted February 14, 2023 Author Share Posted February 14, 2023 It worked out! Thank you very much! Quote Link to comment Share on other sites More sharing options...
Tenare Posted March 22, 2023 Share Posted March 22, 2023 On 2/8/2023 at 5:52 AM, Sherzod said: @sicoobcooplivre Test this approach: function cellkeydown(sender, td, cellIndex, record, tr, rowIndex, e, eOpts) { if (e.event.key == "ArrowRight") { currPos = sender.getOwnerGrid().getSelectionModel().getCurrentPosition(); if (sender.getOwnerGrid().getColumns()[currPos.column].isLastVisible == true) { sender.getOwnerGrid().getSelectionModel().setCurrentPosition({row: currPos.row, column: sender.getOwnerGrid().getVisibleColumnManager().getFirst().getIndex()}); sender.getOwnerGrid().getNavigationModel().setPosition(currPos.row, sender.getOwnerGrid().getVisibleColumnManager().getFirst().getIndex()); return false } } else if (e.event.key == "ArrowLeft") { currPos = sender.getOwnerGrid().getSelectionModel().getCurrentPosition(); if (sender.getOwnerGrid().getColumns()[currPos.column].isFirstVisible == true) { sender.getOwnerGrid().getSelectionModel().setCurrentPosition({row: currPos.row, column: sender.getOwnerGrid().getVisibleColumnManager().getLast().getIndex()}); sender.getOwnerGrid().getNavigationModel().setPosition(currPos.row, sender.getOwnerGrid().getVisibleColumnManager().getLast().getIndex()); return false } } } Hello, I'd like to modify the above code so that the user stops at the last column and doesn't go to the first when pressing "ArrowRight". Similarly, so that the user stops on the first column and doesn't go to the last one when pressing "ArrowLeft". Could you please help me? /Delphi 10.4 UniGUI 1.90.0.1549 Complete - Professional Edition/ Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 23, 2023 Share Posted March 23, 2023 Hello, 7 hours ago, Tenare said: I'd like to modify the above code so that the user stops at the last column and doesn't go to the first when pressing "ArrowRight". Similarly, so that the user stops on the first column and doesn't go to the last one when pressing "ArrowLeft". Could you please help me? function cellkeydown(sender, td, cellIndex, record, tr, rowIndex, e, eOpts) { if (e.event.key == "ArrowRight") { currPos = sender.getOwnerGrid().getSelectionModel().getCurrentPosition(); if (sender.getOwnerGrid().getColumns()[currPos.column].isLastVisible == true) { return false } } else if (e.event.key == "ArrowLeft") { currPos = sender.getOwnerGrid().getSelectionModel().getCurrentPosition(); if (sender.getOwnerGrid().getColumns()[currPos.column].isFirstVisible == true) { return false } } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.