Jump to content

TuniDBGrid: Is it possible to start cell editing when key pressed


Recommended Posts

Posted

Hi Farshad Mohajeri,

 

In TuniDBGrid, is it possible to start cell editing when key pressed? I found some related post in below url:

http://forums.ext.net/showthread.php?17515-CLOSED-GridPanel-start-cell-editing-when-key-pressed

 

When I put below code in ClientEvents.ExtEvents, it doesn't work!

 

function OnKeydown(e)
{
 var me = this,
 grid = me.grid,
 selModel = grid.getSelectionModel(),
 record,
 char = String.fromCharCode(e.getKey());

 pos = selModel.getCurrentPosition();
 record = grid.store.getAt(pos.row); 
 columnHeader = grid.headerCt.getHeaderAtIndex(pos.column);
 me.startEdit(record, columnHeader);
 record[columnHeader.dataIndex] = char;
 Ext.Function.defer(function () {   
   columnHeader.getEditor().field.fireKey(e.RIGHT);  
 },50);
}

Posted

Hi Farshad,

 

Since there is no reply on this topic, I thought no one interest on such functionality. If any one interested, please add a client event to TuniDBGrid as shown below.

  ClientEvents.ExtEvents.add(
      'OnKeypress=function OnKeypress(e)'#13#10+
      '{            var me = '+JSName+','#13#10+
      '             pos  = me.getSelectionModel().getCurrentPosition(),'#13#10+
      '             chrCode = e.getCharCode(),'#13#10+
      '             record = me.store.getAt(pos.row),'#13#10+
      '             colname= me.columns[pos.column].dataIndex,'#13#10+
      '             xplugin = me.getPlugin("uniCellEditor"),'#13#10+
      '             char = String.fromCharCode(chrCode);'#13#10+
      '             record.beginEdit();'#13#10+
      '             record.set(colname, char);'#13#10+
      '             xplugin.startEditByPosition(pos);'#13#10+
      '}');

The most difficult part is I coundn't figure the TuniDBGrid obj in keypress event ("this" didn't work), so I finally use TuniDBGrid.JSName. For me, it works perfectly, but I haven't tested with readonly column.

  • Upvote 2

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