fiorilli Posted July 27, 2021 Share Posted July 27, 2021 Hello, I have a case where I need to select certain rows according to the value of a column in a unidbgrid. Do you have a demo or functionality for these cases? Obs. I looked at this topic http://forums.unigui.com/index.php?/topic/6309-multiselect-unidbgrid-select-rows-programmatically/&_fromLogin=1, but I couldn't solve my case. Link to comment Share on other sites More sharing options...
Sherzod Posted July 27, 2021 Share Posted July 27, 2021 28 minutes ago, fiorilli said: I have a case where I need to select certain rows according to the value of a column in a unidbgrid. Hello, Please provide an example of how you would like to do this. Link to comment Share on other sites More sharing options...
fiorilli Posted July 27, 2021 Author Share Posted July 27, 2021 1 minute ago, Sherzod said: Hello, Please provide an example of how you would like to do this. I have this uniDBGrid, and i want to select the rows with this highlited codes Link to comment Share on other sites More sharing options...
Sherzod Posted July 27, 2021 Share Posted July 27, 2021 3 minutes ago, fiorilli said: I have this uniDBGrid, and i want to select the rows with this highlited codes You'll use a loop to do this? Link to comment Share on other sites More sharing options...
fiorilli Posted July 27, 2021 Author Share Posted July 27, 2021 2 minutes ago, Sherzod said: You'll use a loop to do this? yes Link to comment Share on other sites More sharing options...
Sherzod Posted July 27, 2021 Share Posted July 27, 2021 3 minutes ago, fiorilli said: yes And one more question, it seems you will not use pagination? Link to comment Share on other sites More sharing options...
fiorilli Posted July 27, 2021 Author Share Posted July 27, 2021 Just now, Sherzod said: And one more question, it seems you will not use pagination? correct Link to comment Share on other sites More sharing options...
Sherzod Posted July 27, 2021 Share Posted July 27, 2021 5 minutes ago, fiorilli said: correct Okay. For example, demo: \FMSoft\Framework\uniGUI\Demos\Desktop\GridMultiSelect 1. procedure TMainForm.UniButton1Click(Sender: TObject); begin with UniDBGrid1, UniDBGrid1.DataSource.DataSet do begin DisableControls; First; try while not Eof do begin if (FieldByName('Category').AsString = 'Ray') then JSInterface.JSCode(#1'.getSelectionModel().select('#1'.getStore().data.indexOfKey('+ IntToStr(RecNo-1) +'), true);'); Next; end; finally First; EnableControls; end; end; end; 2. Result: Link to comment Share on other sites More sharing options...
fiorilli Posted July 27, 2021 Author Share Posted July 27, 2021 5 minutes ago, Sherzod said: Okay. For example, demo: \FMSoft\Framework\uniGUI\Demos\Desktop\GridMultiSelect 1. procedure TMainForm.UniButton1Click(Sender: TObject); begin with UniDBGrid1, UniDBGrid1.DataSource.DataSet do begin DisableControls; First; try while not Eof do begin if (FieldByName('Category').AsString = 'Ray') then JSInterface.JSCode(#1'.getSelectionModel().select('#1'.getStore().data.indexOfKey('+ IntToStr(RecNo-1) +'), true);'); Next; end; finally First; EnableControls; end; end; end; 2. Result: ok, I will implement it this way. One question, by selecting the row this way will I be able to find it through UniDBGrid.SelectedRows.Count Link to comment Share on other sites More sharing options...
Sherzod Posted July 27, 2021 Share Posted July 27, 2021 1 minute ago, fiorilli said: by selecting the row this way will I be able to find it through UniDBGrid.SelectedRows.Count Yes. Link to comment Share on other sites More sharing options...
fiorilli Posted July 27, 2021 Author Share Posted July 27, 2021 15 minutes ago, Sherzod said: Yes. When i call de method with button click it works, but when i use other triggers not. Examples: UniDBGrid.AfterLoad, Form.Aftershow. Link to comment Share on other sites More sharing options...
fiorilli Posted July 28, 2021 Author Share Posted July 28, 2021 Hello, Is there any way to allow selecting the row only when clicking on the checkbox?Currently the first row is always selected, and whenever I click on a row all other rows are deselected Hello, Is there any way to allow selecting the row only when clicking on the checkbox?Currently the first row is always selected, and whenever I click on a row all selected rows are unselected. Link to comment Share on other sites More sharing options...
Sherzod Posted July 28, 2021 Share Posted July 28, 2021 9 minutes ago, fiorilli said: Hello, Is there any way to allow selecting the row only when clicking on the checkbox?Currently the first row is always selected, and whenever I click on a row all other rows are deselected Hello, Is there any way to allow selecting the row only when clicking on the checkbox?Currently the first row is always selected, and whenever I click on a row all selected rows are unselected. Hello, Yes. See the Options property. dgCheckSelectCheckOnly = True dgDontShowSelected = True Link to comment Share on other sites More sharing options...
fiorilli Posted July 28, 2021 Author Share Posted July 28, 2021 21 minutes ago, Sherzod said: Is there any way to allow selecting the row only when clicking on the checkbox? This case was solved with dgCheckSelectCheckOnly, but when I activate the dgDontShowSelected property the first record is still always selected and the selection I make in the loop stops working. Link to comment Share on other sites More sharing options...
Sherzod Posted July 28, 2021 Share Posted July 28, 2021 1 minute ago, fiorilli said: but when I activate the dgDontShowSelected property the first record is still always selected and the selection I make in the loop stops working. Hmm, do you have a simple test case to reproduce? Link to comment Share on other sites More sharing options...
fiorilli Posted July 28, 2021 Author Share Posted July 28, 2021 2 minutes ago, Sherzod said: Hmm, do you have a simple test case to reproduce? GridMultiSelect - Checkbox.rarIf you disable the property dgDontShowSelected js row select will work fine. Link to comment Share on other sites More sharing options...
Sherzod Posted July 28, 2021 Share Posted July 28, 2021 8 minutes ago, fiorilli said: GridMultiSelect - Checkbox.rarIf you disable the property dgDontShowSelected js row select will work fine. Okay. I will try to analyze. Link to comment Share on other sites More sharing options...
fiorilli Posted July 28, 2021 Author Share Posted July 28, 2021 14 minutes ago, Sherzod said: Okay. I will try to analyze. Thank you, I look forward to hearing from you. Link to comment Share on other sites More sharing options...
Sherzod Posted July 28, 2021 Share Posted July 28, 2021 1 hour ago, fiorilli said: Thank you, I look forward to hearing from you. Try with "defer" procedure TMainForm.UniDBGrid1AfterLoad(Sender: TUniCustomDBGrid); begin with UniDBGrid1, UniDBGrid1.DataSource.DataSet do begin DisableControls; First; try while not Eof do begin if (FieldByName('Category').AsString = 'Ray') then JSInterface.JSCallDefer('getSelectionModel().select', [RecNo-1, True], 10); Next; end; finally First; EnableControls; end; end; end; Link to comment Share on other sites More sharing options...
fiorilli Posted July 28, 2021 Author Share Posted July 28, 2021 19 minutes ago, Sherzod said: Try with "defer" procedure TMainForm.UniDBGrid1AfterLoad(Sender: TUniCustomDBGrid); begin with UniDBGrid1, UniDBGrid1.DataSource.DataSet do begin DisableControls; First; try while not Eof do begin if (FieldByName('Category').AsString = 'Ray') then JSInterface.JSCallDefer('getSelectionModel().select', [RecNo-1, True], 10); Next; end; finally First; EnableControls; end; end; end; It worked for selecting the rows by js, but the first record still always comes selected. Could you not select the row when calling DataSet.first? Link to comment Share on other sites More sharing options...
fiorilli Posted July 28, 2021 Author Share Posted July 28, 2021 39 minutes ago, fiorilli said: It worked for selecting the rows by js, but the first record still always comes selected. Could you not select the row when calling DataSet.first? Hello, I used JSInterface.JSCallDefer('getSelectionModel().deselect', [0],10); to deselect the first row. Thanks for your help Link to comment Share on other sites More sharing options...
Sherzod Posted July 28, 2021 Share Posted July 28, 2021 OK. Link to comment Share on other sites More sharing options...
Tokay Posted August 23, 2021 Share Posted August 23, 2021 Thanks for all. This topic helped me, all works as expected. The first row could be unselected in the end of all selection with fiorilli code. 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