Jump to content

Recommended Posts

Posted

How do I know when I click on a cell of a grid the position of the mouse in order to display a window / panel for the selection of values ​​to enter?

Posted

Yes.

I need to show a panel near the cell with some input option (waiting for a combobox in the grid :rolleyes: )

 

Position of the mouse? Do you mean the grid cell which is click?

Posted

I think is sufficient.

I will try to show a panel with a list near this position when user click on a cell to enter some data.

 

Do you need a X,Y position?

  • Administrators
Posted

For UniDBGrid:

 

function OnCellmousedown(sender, rowIndex, columnIndex, e)
{
var c = sender.getXY(e);

  ajaxRequest(sender, 'CellXY', ['x='+c.x, 'y='+c.y]);

}

 

Monitor this event on server side to get X and Y.

  • 6 years later...
Posted

Hi Farshad, I needed too to know the position of a clicked cell.

It seems that this solution does not work anymore, maybe the framework has changed meanwhile.

 

function cellmousedown(sender, td, cellIndex, record, tr, rowIndex, e, eOpts)
{
  var c = sender.getXY(e);
alert("c.x"+c.x);
}
 
the above implementaion returns "undefined", which is the correct way to get the coordinates ?
Thank you
Posted

Hi,

function cellmousedown(sender, td, cellIndex, record, tr, rowIndex, e, eOpts)
{
    alert(Ext.get(td).getXY());
}

Sorry, Why do you need it?

Posted

Your solution works well Delphi developer.

I use some images in a DbGrid as action icons, and I need to know the position of the mouse when the image gets clicked (left mouse button)

because I need to popup a popupmenu with some choices in that position.

In fact this solution gives me back the coordinates of the cell, and not the actual coordinates of the mouse.

I would need to have the X,Y coordinates such as in the OnCellContextClick event.

Why the OnCellClick event does not supply X,Y coordinates ?

 

As always thank you.

Posted

Hi Delphi Developer,

your solution finds correctly the coordinates, but I am not able to send them to the server using the ajaxrequest command:

 

function cellmousedown(sender, td, cellIndex, record, tr, rowIndex, e, eOpts)
{
  var c = Ext.get(td).getXY();
  ajaxRequest(sender, 'CellXY', ['x='+c.x, 'y='+c.y]);   
}
 
The above event does not fire anything in the OnAjaxEvent Delphi event. How come ?
Thanks
Andrea
Posted

Hi,

 

Try this:

function cellmousedown(sender, td, cellIndex, record, tr, rowIndex, e, eOpts)
{
    var c = Ext.get(td).getXY();
    ajaxRequest(this, 'CellXY', ['x='+c[0], 'y='+c[1]]);   
}

Best regards,

Posted

Thank you Delphi Developer, it works perfectly. With your support I was able to design an icon on a DbGrid and to popup a menu

on the position of the cell, when it gets clicked.

 

Andrea

  • 4 years later...
Posted
Em 31/07/2017 às 14h00, Sherzod disse:

Oi

 

Tente isso:

function cellmousedown(sender, td, cellIndex, record, tr, rowIndex, e, eOpts)
{
    var c = Ext.get(td).getXY();
    ajaxRequest(this, 'CellXY', ['x='+c[0], 'y='+c[1]]);   
}

Atenciosamente

Good afternoon, I have this approach in a UniDBGrid, when I click on the cell, it opens right, but I have this code

Self.ADserviceVehicle.RecNo := StrToIntDef(Params.Values['rowIndex'], 0) + 1;

to be able to position the line in the dataset, it works.... however when it is paginated, it goes back to page 1.

 

function cellmousedown(sender, td, cellIndex, record, tr, rowIndex, e, eOpts)
{
  var c = Ext.get(td).getXY();
  if (cellIndex > 0) {
    ajaxRequest(this, 'CellXY', ['cellIndex='+cellIndex, 'x='+c[0], 'y='+c[1], 'rowIndex=' + rowIndex]);
  }  
}

 

Posted
8 hours ago, picyka said:

Good afternoon, I have this approach in a UniDBGrid, when I click on the cell, it opens right, but I have this code

Self.ADserviceVehicle.RecNo := StrToIntDef(Params.Values['rowIndex'], 0) + 1;

to be able to position the line in the dataset, it works.... however when it is paginated, it goes back to page 1.

Hello,

Could you please make a simple testcase to see what is wrong?

Posted
5 horas atrás, Sherzod disse:

Olá

Você poderia, por favor, fazer um caso de teste simples para ver o que está errado?

Good morning, go to page 2, then in the first column click on it, note that it will go back to page 1

Demo.zip

Posted
11 minutes ago, picyka said:

Good morning, go to page 2, then in the first column click on it, note that it will go back to page 1

Hello,

Why not use the OnCellContextClick event?

Posted
7 minutos atrás, Sherzod disse:

Desculpa?

The system default eg left click on the icons, it would be a little strange... it would be difficult to execute

this line

 

UniMainModule.DataSource.DataSet.RecNo := StrToIntDef(Params.Values['rowIndex'], 0) + 1;

 

I believe that it would just be multiplying by the page that it is...

 

UniMainModule.DataSource.DataSet.RecNo := StrToIntDef(Params.Values['rowIndex'], 0) * (pageIndex + 1) + 1;

Posted
30 minutos atrás, Sherzod disse:

Por que você precisa disso?

procedure TUniFrameConsAtendVeiculo.UniDBGridConsultaAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings);
begin
  if (EventName.Equals('CellXY') and (Params.Values['cellIndex'] = '11')) then
  begin
    Self.ADAtendimentoVeiculo.RecNo := StrToIntDef(Params.Values['rowIndex'], 0) + 1;
    UniPMAcoes.Popup(Params.Values['x'].ToInteger, Params.Values['y'].ToInteger)
  end
end;

The code stays in the ajax event, so I need to position the dataset cursor..

 

Another detail, that I use an ActionColumn, it seems that if you click on the image, it doesn't position..

Posted
Em 23/11/2021 às 9h37, Picyka disse:
procedure TUniFrameConsAtendVeiculo.UniDBGridConsultaAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings);
begin
  if (EventName.Equals('CellXY') and (Params.Values['cellIndex'] = '11')) then
  begin
    Self.ADAtendimentoVeiculo.RecNo := StrToIntDef(Params.Values['rowIndex'], 0) + 1;
    UniPMAcoes.Popup(Params.Values['x'].ToInteger, Params.Values['y'].ToInteger)
  end
end;

O código permanece no evento ajax, então eu preciso posicionar o cursor dataset..

 

Outro detalhe, que eu uso um ActionColumn, parece que se você clicar na imagem, ele não se posiciona..

function cellmousedown(sender, td, cellIndex, record, tr, rowIndex, e, eOpts)
{
  var c = Ext.get(td).getXY();
  
  var rec = sender.getStore().getAt(rowIndex);  
  
  if (cellIndex > 0) {
    ajaxRequest(this, 'CellXY', ['cellIndex='+cellIndex, 'x='+c[0], 'y='+c[1], 'recNo=' + rec.id]);
  }  
}
procedure TUniFrameConsAtendVeiculo.UniDBGridConsultaAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings);
begin
  if (EventName.Equals('CellXY') and (Params.Values['cellIndex'] = '11')) then
  begin
    Self.ADAtendimentoVeiculo.RecNo := StrToIntDef(Params.Values['recNo'], 0) + 1;
    UniPMAcoes.Popup(Params.Values['x'].ToInteger, Params.Values['y'].ToInteger)
  end
end;

 

Posted
16 horas atrás, picyka disse:
function cellmousedown(sender, td, cellIndex, record, tr, rowIndex, e, eOpts)
{
  var c = Ext.get(td).getXY();
  
  var rec = sender.getStore().getAt(rowIndex);  
  
  if (cellIndex > 0) {
    ajaxRequest(this, 'CellXY', ['cellIndex='+cellIndex, 'x='+c[0], 'y='+c[1], 'recNo=' + rec.id]);
  }  
}
procedure TUniFrameConsAtendVeiculo.UniDBGridConsultaAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings);
begin
  if (EventName.Equals('CellXY') and (Params.Values['cellIndex'] = '11')) then
  begin
    Self.ADAtendimentoVeiculo.RecNo := StrToIntDef(Params.Values['recNo'], 0) + 1;
    UniPMAcoes.Popup(Params.Values['x'].ToInteger, Params.Values['y'].ToInteger)
  end
end;

 

if (EventName.Equals('CellXY') and (Params.Values['cellIndex'] = '11')) then    
  UniPMAcoes.Popup(Params.Values['x'].ToInteger, Params.Values['y'].ToInteger) 


function cellmousedown(sender, td, cellIndex, record, tr, rowIndex, e, eOpts)
{
  var me= this;
  
  var c = Ext.get(td).getXY();    
  
  if (cellIndex > 0) {
    Ext.defer(function() {
       ajaxRequest(me, 'CellXY', ['cellIndex='+cellIndex, 'x='+c[0], 'y='+c[1]]);
    }, 200);
  }  
}
 

Alternative suggested by Sherzod

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...