Jump to content

DBGrid Title Popup Menu Events


mos

Recommended Posts

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

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

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

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

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...