Jump to content

ActionClick ShowMask


picyka

Recommended Posts

When clicking on an ActionClick to open a form, I would like it to display a mask until the form opens. What would be the correct way to do this?

 

procedure TUniFrameCadFornecedor.UniDBGridServicosColumnActionClick(Column: TUniDBGridColumn; ButtonId: Integer);
begin
  case ButtonId of
    0:
    begin
      with TUniFormCadFornecedorServico.Create(UniApplication) do
      begin
        try
          ShowForm(Self.ADFornecedorServico.Current<TFornecedorServico>, acEdit, Self.Controller);

          if ModalResult = mrOk then
            Self.ADFornecedorServico.Refresh;
        finally
          Free;
        end;
      end;
    end;

    1:
    begin
      if TMessageUtils.Question(_MENSAGEM_EXCLUSAO) = mrYes then
        Self.ADFornecedorServico.Delete;
    end;
  end;
end;

 

Link to comment
Share on other sites

36 minutes ago, picyka said:

When clicking on an ActionClick to open a form, I would like it to display a mask until the form opens. What would be the correct way to do this?

Hello,

You can try something like this:

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  UniDBGrid1.JSInterface.JSAddListener('actionclick', 'function(){this.showMask("Action icon clicked...")}');
end;

 

Link to comment
Share on other sites

45 minutes ago, Sherzod said:

Hello,

You can try something like this:

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  UniDBGrid1.JSInterface.JSAddListener('actionclick', 'function(){this.showMask("Action icon clicked...")}');
end;

 

Master, something unexpected always appears. I would be able to display the mask according to the ButtonId I'm looking in the ExtsJs documentation and I didn't find anything about this.

Link to comment
Share on other sites

Just now, Sherzod said:

Could you please explain in more detail?

procedure TUniDBGridHelper.ConfigureColumAction(SetEvents : Boolean);
var
  lCoumn: TUniBaseDBGridColumn;
begin
  if Assigned(Self) then
  begin
    Self.JSInterface.JSAddListener('actionclick', 'function(itemId){alert(itemId.value);  this.showMask("Aguarde processando...")}');

    lCoumn := Self.ColumnByName('actions');

    if lCoumn <> nil then
    begin
      if SetEvents then
      begin
        if not Assigned(Self.OnDblClick) then
          Self.OnDblClick := Self._MyDblClick;

        if not Assigned(Self.OnKeyDown) then
          Self.OnKeyDown := Self._MyKeyDown;
      end;

      lCoumn.Width := 57;
      lCoumn.Alignment := taCenter;
      lCoumn.Title.Caption := 'Ações';
      lCoumn.Title.Alignment := taCenter;
      lCoumn.ActionColumn.Enabled := True;

      lCoumn.ActionColumn.Buttons.Add;
      lCoumn.ActionColumn.Buttons[0].ButtonId := 0;
      lCoumn.ActionColumn.Buttons[0].Hint := 'Editar';
      lCoumn.ActionColumn.Buttons[0].ImageIndex := 1;

      lCoumn.ActionColumn.Buttons.Add;
      lCoumn.ActionColumn.Buttons[1].ButtonId := 1;
      lCoumn.ActionColumn.Buttons[1].Hint := 'Excluir';
      lCoumn.ActionColumn.Buttons[1].ImageIndex := 16;
    end
    else
    begin
      lCoumn := Self.ColumnByName('del');

      if Assigned(lCoumn) then
      begin
        lCoumn.ActionColumn.Enabled := True;
        with lCoumn.ActionColumn.Buttons[0] do
        begin
          Hint := 'Excluir';
          ImageIndex := 16;
        end;
      end;

      lCoumn := Self.ColumnByName('edit');

      if Assigned(lCoumn) then
      begin
        lCoumn.ActionColumn.Enabled := True;
        with lCoumn.ActionColumn.Buttons[0] do
        begin
          Hint := 'Editar';
          ImageIndex := 1;
        end;
      end;
    end;
  end;
end;

I just need the mask to fire only with ButtonId = 0 or ButtonId = 1

Link to comment
Share on other sites

9 minutes ago, picyka said:

I just need the mask to fire only with ButtonId = 0 or ButtonId = 1

Try this approach:

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  UniDBGrid1.JSInterface.JSAddListener('actionclick', 'function(actionCol, buttonId){if (buttonId<2) {this.showMask("Action icon clicked...")}}');
end;

 

Link to comment
Share on other sites

×
×
  • Create New...