mos Posted August 6, 2020 Share Posted August 6, 2020 Is it possible to tell when the popup menu below appears and when it closes via events: Link to comment Share on other sites More sharing options...
Sherzod Posted August 6, 2020 Share Posted August 6, 2020 Hello, For what purpose do you need? Link to comment Share on other sites More sharing options...
mos Posted August 6, 2020 Author Share Posted August 6, 2020 Hi Sherzod, I have a UniTimer that is used to refresh the query by closing and then reopening it. I would like to disable the timer when this popup menu appears and re-enabled it when the popup menu is closed. Link to comment Share on other sites More sharing options...
Sherzod Posted August 6, 2020 Share Posted August 6, 2020 1 hour ago, mos said: I would like to disable the timer when this popup menu appears and re-enabled it when the popup menu is closed. Hi, One possible solution: UniDBGrid1.ClientEvents.ExtEvents - > function viewready(sender, eOpts) { var me=sender; var header = sender.headerCt; if (header && header.getMenu()) { header.getMenu().addListener('show', function(){ //console.log("show") ajaxRequest(me, ...) }); header.getMenu().addListener('hide', function(){ //console.log("hide") ajaxRequest(me, ...) }) } } Link to comment Share on other sites More sharing options...
Sherzod Posted August 6, 2020 Share Posted August 6, 2020 2 hours ago, mos said: I would like to disable the timer when this popup menu appears and re-enabled it when the popup menu is closed. function viewready(sender, eOpts) { var me=sender; var header = sender.headerCt; if (header && header.getMenu()) { header.getMenu().addListener('show', function(){ //console.log("show") ajaxRequest(me, '_show', []) }); header.getMenu().addListener('hide', function(){ //console.log("hide") ajaxRequest(me, '_hide', []) }) } } procedure TMainForm.UniDBGrid1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName = '_show' then begin // end else if EventName = '_hide' then begin // end; end; Link to comment Share on other sites More sharing options...
mos Posted August 6, 2020 Author Share Posted August 6, 2020 Thanks Sherzod. I have another issue. I have a test app where in runtime I set the Sortable property of each of the columns to True. Howerver when I click on the column header the popup menu has the Sort Ascending and Sort Descending disabled. Here is the code I used: procedure TMainForm.UniDBGrid1AfterLoad(Sender: TUniDBGrid); var liX: Integer; begin for liX := 0 to UniDBGrid1.Columns.Count - 1 do UniDBGrid1.Columns[liX].Sortable := True; end; procedure TMainForm.UniDBGrid1ColumnSort(Column: TUniDBGridColumn; Direction: Boolean); begin ADOTable1.Close; ADOTable1.Open; end; procedure TMainForm.UniFormShow(Sender: TObject); begin ADOTable1.Open; end; Can you tell me why those menu options are not enabled? Link to comment Share on other sites More sharing options...
Sherzod Posted August 6, 2020 Share Posted August 6, 2020 1 hour ago, mos said: Can you tell me why those menu options are not enabled? This should be set at design time. Link to comment Share on other sites More sharing options...
mos Posted August 6, 2020 Author Share Posted August 6, 2020 Hi Sherzod, Is there any reason why the code doesn't work at runtime as I have a DBGrid in a frame which can display different result sets with different columns? Link to comment Share on other sites More sharing options...
Sherzod Posted August 6, 2020 Share Posted August 6, 2020 Hi, Can you make a simple testcase? Link to comment Share on other sites More sharing options...
mos Posted August 7, 2020 Author Share Posted August 7, 2020 Hi Sherzod, I can send you a test project but it was connecting to a table in a SQL Server database. You will need to set the connection and table name. DBGrid Sort.zip Link to comment Share on other sites More sharing options...
Sherzod Posted August 7, 2020 Share Posted August 7, 2020 Hi, 4 hours ago, mos said: You will need to set the connection and table name. How? Link to comment Share on other sites More sharing options...
mos Posted August 7, 2020 Author Share Posted August 7, 2020 Do you have any test SQL Server database you can use as that is what I am using? Link to comment Share on other sites More sharing options...
Sherzod Posted August 7, 2020 Share Posted August 7, 2020 9 minutes ago, mos said: Do you have any test SQL Server database you can use as that is what I am using? Can you make a simple testcase, for example using ClientDataSet? Link to comment Share on other sites More sharing options...
mos Posted August 10, 2020 Author Share Posted August 10, 2020 Hi Sherzod, I modified the csort demo to demonstrate the issue. csort.zip Link to comment Share on other sites More sharing options...
Sherzod Posted August 10, 2020 Share Posted August 10, 2020 4 hours ago, mos said: I modified the csort demo to demonstrate the issue. csort.zip Hi, Sorry, is this about enabling sorting in runtime? Link to comment Share on other sites More sharing options...
mos Posted August 10, 2020 Author Share Posted August 10, 2020 Yes enabling the sort menus. Link to comment Share on other sites More sharing options...
Sherzod Posted August 10, 2020 Share Posted August 10, 2020 3 minutes ago, mos said: Yes enabling the sort menus. Can you try to use this approach?: procedure TMainForm.UniDBGrid1AfterLoad(Sender: TUniDBGrid); var liX: Integer; begin for liX := 0 to UniDBGrid1.Columns.Count - 1 do begin UniDBGrid1.Columns[liX].Sortable := True; UniDBGrid1.JSInterface.JSAssign('sortable', [UniDBGrid1.Columns[liX].Sortable], UniDBGrid1.Columns[liX].JSColumn); //<----- end; end; 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