abhimanyu Posted January 9, 2017 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? Quote
Sherzod Posted January 9, 2017 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. Quote
abhimanyu Posted January 9, 2017 Author Posted January 9, 2017 Showing JSInterface is undeclared identifier. Quote
Sherzod Posted January 9, 2017 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();'); Quote
pavell Posted January 9, 2017 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? Quote
abhimanyu Posted January 9, 2017 Author 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? Quote
Sherzod Posted January 9, 2017 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();'); Quote
abhimanyu Posted January 9, 2017 Author Posted January 9, 2017 UniSession.AddJS(UniDBGrid1.JSName + '.getSelectionModel().selectAll'); Correct: UniSession.AddJS(UniDBGrid1.JSName + '.getSelectionModel().selectAll();'); Oh Sorry :p, Thank you very much ! Quote
abhimanyu Posted January 10, 2017 Author 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. Quote
Sherzod Posted January 10, 2017 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): ... Quote
rgreat Posted November 15, 2023 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. Quote
Sherzod Posted November 15, 2023 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 Quote
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.