Jump to content

Cell grid position


ldb68

Recommended Posts

  • 6 years later...

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 4 years later...
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]);
  }  
}

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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;

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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;

 

Link to comment
Share on other sites

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

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