Jump to content

Recommended Posts

Posted

Hi!

 

I need to get the row and col when the user selects a new cell in the grid. The user can change using mouse or keyboard.

 

Anyone know how to get this?

 

I tried using OnCellClick but it fires only when the user clicks the mouse. I need to get after using the keyboard too.

 

Thank you!

 

Bruno

Posted


procedure UniForm1.UniDBGrid1AjaxEvent(Sender: TComponent;
EventName: string; Params: TStrings);
begin

if EventName = 'select' then
begin
editrow.Text := 'row = '+Params.ValueFromIndex[5];
editcolumn.Text := 'column = '+Params.ValueFromIndex[6];
end;
end;

post-856-0-00773300-1371566538_thumb.png

post-856-0-27213700-1371566549_thumb.png

post-856-0-91433500-1371566558_thumb.png

Posted

Thank you!

 

Solved here too.

 

function OnCellclick(sender, rowIndex, columnIndex, e)
{
  var me = MainForm.UniDBGrid1;
  pos = me.getSelectionModel().getCurrentPosition();
  //alert(pos.column);
 
  ajaxRequest(MainForm.UniDBGrid1,
              'CellChanged',
              ['col='+pos.column,'row='+pos.row]);
}

 

 

function OnKeypress(e)
{
  var me = MainForm.UniDBGrid1;
  pos = me.getSelectionModel().getCurrentPosition();
  //alert(pos.column);
 
  ajaxRequest(MainForm.UniDBGrid1,
              'CellChanged',
              ['col='+pos.column,'row='+pos.row]);
}

 

 

 

 

OnAjaxEvent

 

var
  col, row: string;
begin
  if EventName='CellChanged' then
  begin
    col := Params.Values['col'];
    row := Params.Values['row'];
    if (UpperCase(col)<>'UNDEFINED')and(UpperCase(row)<>'UNDEFINED') then
    begin
        UniLabel1.Text := 'Col: ' + col + ', Row: ' + row;

    end;

end;

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