abhimanyu Posted January 9, 2017 Share Posted January 9, 2017 Hi, I want to select all rows and deselect all rows on one button click, Is that any property is exist for TUniDBGrid or not for do this? or need to write code manually selecting all rows and deselecting all rows? Link to comment Share on other sites More sharing options...
Sherzod Posted January 9, 2017 Share Posted January 9, 2017 Hi, For now can you try this?!: procedure TMainForm.UniButton1Click(Sender: TObject); begin UniDBGrid1.JSInterface.JSCall('getSelectionModel().selectAll', []); end; procedure TMainForm.UniButton2Click(Sender: TObject); begin UniDBGrid1.JSInterface.JSCall('getSelectionModel().deselectAll', []); end; Best regards. Link to comment Share on other sites More sharing options...
abhimanyu Posted January 9, 2017 Author Share Posted January 9, 2017 Showing JSInterface is undeclared identifier. Link to comment Share on other sites More sharing options...
Sherzod Posted January 9, 2017 Share Posted January 9, 2017 Which build are you using?! Also you can use like this: UniSession.AddJS(UniDBGrid1.JSName + '.getSelectionModel().selectAll();'); UniSession.AddJS(UniDBGrid1.JSName + '.getSelectionModel().deselectAll();'); Link to comment Share on other sites More sharing options...
pavell Posted January 9, 2017 Share Posted January 9, 2017 Hi all, If DBGrid finde this situation: procedure TfrmXXX.gridMainMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin If Shift=[ssAlt] Then inherited; // end; procedure TfrmXXX.gridMainMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin If Shift=[ssAlt] Then inherited; // end; Value of Shift is always '[]'. i.e. i can't catch pressed button SHIFT, ALT, CTRL. What is this, bug? Link to comment Share on other sites More sharing options...
abhimanyu Posted January 9, 2017 Author Share Posted January 9, 2017 Which build are you using?! Also you can use like this: UniSession.AddJS(UniDBGrid1.JSName + '.getSelectionModel().selectAll();'); UniSession.AddJS(UniDBGrid1.JSName + '.getSelectionModel().deselectAll();'); procedure TMainForm.UniButton1Click(Sender: TObject); begin UniSession.AddJS(UniDBGrid1.JSName + '.getSelectionModel().selectAll'); ShowMessage(IntToStr(UniDBGrid1.SelectedRows.Count)); end; After clicking on button it will not showing the count of all rows and not selecting all records. Is that need anything else to call that JS? Link to comment Share on other sites More sharing options...
Sherzod Posted January 9, 2017 Share Posted January 9, 2017 procedure TMainForm.UniButton1Click(Sender: TObject); begin UniSession.AddJS(UniDBGrid1.JSName + '.getSelectionModel().selectAll'); ShowMessage(IntToStr(UniDBGrid1.SelectedRows.Count)); end; After clicking on button it will not showing the count of all rows and not selecting all records. Is that need anything else to call that JS? UniSession.AddJS(UniDBGrid1.JSName + '.getSelectionModel().selectAll'); Correct: UniSession.AddJS(UniDBGrid1.JSName + '.getSelectionModel().selectAll();'); Link to comment Share on other sites More sharing options...
abhimanyu Posted January 9, 2017 Author Share Posted January 9, 2017 UniSession.AddJS(UniDBGrid1.JSName + '.getSelectionModel().selectAll'); Correct: UniSession.AddJS(UniDBGrid1.JSName + '.getSelectionModel().selectAll();'); Oh Sorry :p, Thank you very much ! Link to comment Share on other sites More sharing options...
abhimanyu Posted January 10, 2017 Author Share Posted January 10, 2017 procedure TMainForm.SelectALLClick(Sender: TObject); begin UniSession.AddJS(UniDBGrid1.JSName + '.getSelectionModel().selectAll();'); ShowMessage(inttostr(UniDBGrid1.SelectedRows.Count)); end; procedure TMainForm.UnSelectAllClick(Sender: TObject); begin UniSession.AddJS(UniDBGrid1.JSName + '.getSelectionModel().deselectAll()'); ShowMessage(inttostr(UniDBGrid1.SelectedRows.Count)); end; In my case it not showing proper count of the selected records. If I select 2 record and then click on SelectALL it gives me count is 2 after that if I click on UnSelectAll it gives me total count and again If I click on SelectALL it gives me count 0. I am not sure what I missing. Link to comment Share on other sites More sharing options...
Sherzod Posted January 10, 2017 Share Posted January 10, 2017 Hi, In my case it not showing proper count of the selected records. If I select 2 record and then click on SelectALL it gives me count is 2 after that if I click on UnSelectAll it gives me total count and again If I click on SelectALL it gives me count 0. I am not sure what I missing. Then try this: 1. UniButton1 (selectAll): UniButton1->ClientEvents->ExtEvents-> click fn: function click(sender, e, eOpts) { MainForm.UniDBGrid1.getSelectionModel().selectAll(); } procedure TMainForm.UniButton1Click(Sender: TObject); begin ShowMessage(inttostr(UniDBGrid1.SelectedRows.Count)); end; 2. UniButton2 (deselectAll): ... Link to comment Share on other sites More sharing options...
rgreat Posted November 15, 2023 Share Posted November 15, 2023 UniSession.AddJS(UniDBGrid1.JSName + '.getSelectionModel().deselectAll();'); Only works if called after grid is finished loading at front-end. Which happens after some unknown amount of time. Can I deselect everything all in a timely manner? Or even better disable auto selection of the first row on grid open. Link to comment Share on other sites More sharing options...
Sherzod Posted November 15, 2023 Share Posted November 15, 2023 1 hour ago, rgreat said: Can I deselect everything all in a timely manner? Or even better disable auto selection of the first row on grid open. 1 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