ldb68 Posted July 7, 2011 Posted July 7, 2011 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? Quote
Administrators Farshad Mohajeri Posted July 7, 2011 Administrators Posted July 7, 2011 Position of the mouse? Do you mean the grid cell which is click? Quote
ldb68 Posted July 7, 2011 Author Posted July 7, 2011 Yes. I need to show a panel near the cell with some input option (waiting for a combobox in the grid ) Position of the mouse? Do you mean the grid cell which is click? Quote
Administrators Farshad Mohajeri Posted July 7, 2011 Administrators Posted July 7, 2011 Do you need a X,Y position? Quote
ldb68 Posted July 7, 2011 Author Posted July 7, 2011 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? Quote
Administrators Farshad Mohajeri Posted July 7, 2011 Administrators Posted July 7, 2011 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. Quote
arilotta Posted July 25, 2017 Posted July 25, 2017 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 Quote
Sherzod Posted July 25, 2017 Posted July 25, 2017 Hi, function cellmousedown(sender, td, cellIndex, record, tr, rowIndex, e, eOpts) { alert(Ext.get(td).getXY()); } Sorry, Why do you need it? Quote
arilotta Posted July 26, 2017 Posted July 26, 2017 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. Quote
arilotta Posted July 31, 2017 Posted July 31, 2017 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 Quote
Sherzod Posted July 31, 2017 Posted July 31, 2017 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, Quote
arilotta Posted August 1, 2017 Posted August 1, 2017 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 Quote
picyka Posted November 22, 2021 Posted November 22, 2021 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]); } } Quote
Sherzod Posted November 23, 2021 Posted November 23, 2021 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? Quote
picyka Posted November 23, 2021 Posted November 23, 2021 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 Quote
Sherzod Posted November 23, 2021 Posted November 23, 2021 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? Quote
picyka Posted November 23, 2021 Posted November 23, 2021 8 minutos atrás, Sherzod disse: Olá Por que não usar o evento OnCellContextClick? Good question, it would be boring to explain to users... Quote
Sherzod Posted November 23, 2021 Posted November 23, 2021 25 minutes ago, Sherzod said: the OnCellContextClick event So is this okay for you? Quote
picyka Posted November 23, 2021 Posted November 23, 2021 9 minutos atrás, Sherzod disse: Então, está tudo bem para você? Would it be difficult to sync the dataset? Quote
Sherzod Posted November 23, 2021 Posted November 23, 2021 2 minutes ago, picyka said: Would it be difficult to sync the dataset? Sorry? Quote
picyka Posted November 23, 2021 Posted November 23, 2021 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; Quote
Sherzod Posted November 23, 2021 Posted November 23, 2021 18 minutes ago, picyka said: UniMainModule.DataSource.DataSet.RecNo Why do you need this? Quote
picyka Posted November 23, 2021 Posted November 23, 2021 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.. Quote
picyka Posted November 29, 2021 Posted November 29, 2021 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; Quote
picyka Posted November 30, 2021 Posted November 30, 2021 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.