Jump to content

Intercept OnClick event inside UniDBGrid's store.load


Fábio Matte

Recommended Posts

Intercept OnClick event that is inside UniDBGrid's store.load.

I created a code with CSS and also customized the display of data in a UniDBGRID (see attached images).

I would like to intercept the OnClick event that is inside store.load.

By clicking this button, execute some routine within the Application.

How could I do it correctly?

 

CODE:

function store.load(sender, records, successful, operation, eOpts)
{
  sender.grid.getColumns()[0].renderer = function (value, metadata, record) {
    var imagePath = '';
    if (!imagePath || imagePath === '') {
        imagePath = '/img/clientes.png';  // Imagem padrão
    }
    
    var description = record.get('1');
    if (description.length > 800) {
        description = description.substring(0, 800) + ' ...'; 
    }
        
    metadata.tdAttr = 'data-qclass="dvQtip" data-qtip="' + record.get('0') + '"';
    return '<div class="dvContainer">'+
      '<table class="tableContent"> ' +
        '<tr>'+
          '<td class="thumbnailCell">' +
            '<img src="' + imagePath + '" class="thumbnail">' + 
          '</td>' +
          '<td>'+
            '<table class="tableContent"> ' +
              '<tr>'+
                '<td class="divTitle" colspan="3">'+  // Atualizar o colspan para 3
                  '' + record.get('0') +
                '</td>'+
              '</tr>'+
              '<tr>'+
                '<td class="divSubTitle" colspan="3">'+
                  '<span class="labelDesc">Descrição:</span>' + description +
                '</td>'+
              '</tr>'+     
              '<tr>'+
                '<td class="divCity" colspan="3">'+
                  '<span class="labelTemp">Temporalidade:</span>' + record.get('2') +
                '</td>'+
              '</tr>'+
              '<tr>'+
                '<td class="divCity" colspan="3">'+
                  '<span class="labelTemp">Localização:</span>' + record.get('7') +
                '</td>'+
              '</tr>'+      
              '<tr>'+ 
                '<td class="divNewClass1">'+
                  '<span class="labelDesc">Data do Documento:</span>' + record.get('4') +
                '</td>'+
                '<td class="divNewClass2">'+
                  '<span class="labelDesc">Data do Descarte:</span>' + record.get('5') +
                '</td>'+
                '<td class="divNewClass1">'+
                  '<span class="labelDesc">N.º Documento:</span>' + record.get('6') +
                '</td>'+                
              '</tr>'+
            '</table>'+ 
          '</td>'+
          '<td>'+
            '<div class="fileLink" onclick="showPnlArquivos();">' +
              '<img src="/css/img/ged/files-48.png" alt="Arquivos" />' +
              '<span>Arquivos</span>'+
            '</div>'+
          '</td>'+
        '</tr>'+
      '</table>'+        
    '</div>';                            
  }; 

  sender.grid.getView().refresh(); 
}

 

UniDBGRID.jpg

Screenshot_2.jpg

Link to comment
Share on other sites

I defined it inside a UniHTMLFrame that is inside the form that contains the DBGrid.

image.thumb.png.deddd6240aa7e1355b32b7f7d28f5314.png

function showPnlArquivos(panelID) {
    var panel = Ext.getCmp(panelID);
    if(panel) {
        panel.setVisible(true);
    }
    ajaxRequest(frameGED_PesquisaAvancada.dbGridResultado, 'showPanelClick', []);
}

 

And then I put the following in OnAjaxEvent:

procedure TframeGED_PesquisaAvancada.dbGridResultadoAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings);
begin
  if EventName = 'showPanelClick' then
  begin
    pnlArquivos.Visible := True;
  end;
end;

 

When I open the application, the following error ends up happening:

Imagem carregada

 

Form OnCreate:

JSName := pnlArquivos.JSName;
JSCode := Format('showPnlArquivos(''%s'');', [JSName]);
UniSession.AddJS(JSCode);

 

 

 

Link to comment
Share on other sites

  • 4 months later...
On 14/02/2024 at 00:57, Sherzod said:

@Fábio Matte

Olá,

Desculpe, você conseguiu?

Good afternoon @Sherzod, yes, with a lot of research and testing I got where I needed to be, now my buttons are responding to clicks as I planned, it looks very good.

I'm going to make a brief tutorial and put it here in this thread to help others who need it.

Thank you very much.

  • Thanks 1
  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...