Select the event
select the event in the selected block changes occur issued.
table.addKDTSelectListener (new new KDTSelectListener ()
{
public void tableSelectChanged (KDTSelectEvent E) {
// Get a selection block
KDTSelectBlock sbPrev e.getPrevSelectBlock = ();
// get the current selection block
KDTSelectBlock sbCurr e.getSelectBlock = ();
// do something ...
}
});
click, double-click events
click event is issued after a mouse click on a cell.
Double-click the mouse double-click event is issued after a grid unit.
table.addKDTMouseListener (new new KDTMouseListener ()
{
public void tableClicked (KDTMouseEvent E)
{
// click
IF (e.getClickCount () ==. 1)
{
// do something ...
}
// Double-
IF the else (e.getClickCount () == 2)
{
// do something ...
}
}
});
activating unit refers in this unit is ready to enter the edit mode.
The activation unit change event is issued after activation unit changes.
Add activation unit change event listener
table.addKDTActiveCellListener (new new KDTActiveCellListener ()
{
public void activeCellChanged (KDTActiveCellEvent E)
{
// activate a row index obtaining unit
int prevRow e.getPrevRowIndex = ();
int = e.getPrevColumnIndex prevCol ();
// get the current active unit ranks index
int currRow = e.getRowIndex ();
int currCol = e.getColumnIndex ();
// ... do something
}
});
edit event
edit event KDTEditListener include the following method:
editStarting editor starts, before starting the editor sent, the return value can be canceled by setting the start editor.
After editStarted edit the boot, issued after edit start.
editValueChanged value change editor, the editor issued after the value is changed.
End editStopping editor, the editor sent before the end, the return value can be canceled by setting the end of the editor.
After editStopped editor, issued after the end of the editor.
KDTEditListener provides adapters KDTEditAdapter
// example
table.addKDTEditListener (new new KDTEditAdapter ()
{
// editor before starting
public void editStarting (KDTEditEvent E)
{
System.out.println ( "editStarting");
// if the current line is the third OK, cancel the edit
IF (e.getRowIndex () ==. 3)
e.setCancel (to true);
}
// after editing start
public void editStarted (KDTEditEvent E)
{
System.out.println ( "editStarted");
// if the current cell is in the fourth row 0, and the unit value is a string, the string with the $ character before
if ((e.getRowIndex () == 4 ) && (e.getColIndex () == 0))
{
KDTable = TBL (KDTable) e.getSource ();
Object value = tbl.getEditManager () getEditor () the getValue ();..
IF (the instanceof String value)
tbl.getEditManager () getEditor () the setValue.. ( "$" + value.toString ());
}
}
// editor value changes (Note: the editor is not over, KDTable actually forwarded editor
// change event)
public void editValueChanged (KDTEditEvent E ) {
System.out.println ( "editValueChanged");
}
// end editor
public void editStopping (KDTEditEvent E)
{
System.out.println ( "editStopping");
// if the current cell is in the fourth row 0, then the $ character before exiting remove
IF ((e.getRowIndex () == 4) && (e.getColIndex () == 0))
{
KDTable TBL = ( KDTable) e.getSource ();
.. String value = (String) tbl.getEditManager () getEditor () the getValue ();
// if the value is less than the length of the cell 5 is not allowed to exit the edit mode
if (value.length () <5)
e.setCancel (to true);
// otherwise, get $ character and exit the editor
the else
tbl.getEditManager () getEditor () setValue (value.substring (1, value.length ()..));
}
}
// edit after
public void editStopped (KDTEditEvent E) {
System.out.println ( "editStopped");
}
});
BeforeActionListener event
This event ranks in the table additions and deletions as well as copy, paste, cut when the trigger appropriate action can be canceled by setting the return value of the event parameter.
// table to set Action
table.setBeforeAction (new new TableBeforeAction ());
// implementation Action
class TableBeforeAction the implements BeforeActionListener
{
/ **
* # @ See com.kingdee.bos.ctrl.kdf.table.event.BeforeActionListener the beforeAction ( com.kingdee.bos.ctrl.kdf.table.event.BeforeActionEvent)
* /
public void the beforeAction (BeforeActionEvent E)
{
// add the line
IF (e.getType () == BeforeActionEvent.ACTION_ADD_ROW)
{
// Get insert row position
int rowIndex = ((Integer) e.getParameter ()) intValue ().;
IF (rowIndex>. 5)
{
WindowUtil.msgboxInfo ( "not add line", "title", Table);
// cancellation action
e.setCancel (to true);
}
}
// add columns
else if (e.getType () = BeforeActionEvent.ACTION_ADD_COLUMN =)
{
int colIndex, = ((Integer) e.getParameter ()) intValue ();.
IF (colIndex,>. 3)
{
WindowUtil.msgboxInfo ( "not add columns", "title", Table);
// cancellation action
e.setCancel (to true);
}
}
Paste //
the else IF (e.getType () == BeforeActionEvent.ACTION_PASTE)
{
// Get paste items
. Mark int = ((Integer) e.getParameter ()) intValue ();
// if the key contains userObject paste , then
IF (KDTEditHelper.isUserObject (Mark))
{
WindowUtil.msgboxInfo ( "Paste", "title", Table);
// Paste content except the userObject
. table.getEditHelper () paste (KDTEditHelper.STYLE | KDTEditHelper.VALUE | KDTEditHelper.FORMULA);
// cancel action
e.setCancel (to true);
}
}
// Cut
if the else (e.getType () == BeforeActionEvent.ACTION_CUT)
{
// Get cut items
int Mark = ((Integer) e.getParameter ()) intValue ();.
// If the entry contains cut userObject, then
if (KDTEditHelper.isUserObject (Mark))
{
WindowUtil.msgboxInfo ( "Cut", "title", Table);
// Cut the content except userObject
. table.getEditHelper () paste (KDTEditHelper.STYLE | KDTEditHelper.VALUE | KDTEditHelper. the FORMULA);
// cancellation action
e.setCancel (to true);
}
}
}
}
eas of events
Guess you like
Origin www.cnblogs.com/luojiabao/p/10963822.html
Recommended
Ranking