aminef
15 Dec 2010, 7:58 AM
BasicallyI have a listener on my grid that allows a delete (on pressing "del" key) and an add (using the "+" key) both of them work great!
I wanted to add to the listener that if the key pressed is a letter, then show a dialog. and the problems start...
1) when the last feature is added, I can't navigate with the arrows on my grid, and can't use the "del" and the "+" keys
2) when I press a key to show the dialog, the be.getValue() (witch is supposed to be the letter typed, is always empty string)
3) and finally when I try to use the startsWith() method, it doesn't work...
Here is my code in order:
the grid listener:
grid.addListener(Events.OnKeyDown, new Listener<GridEvent<PersInfo>>() {
@Override
public void handleEvent(GridEvent<PersInfo> be) {
PersInfo rowData = grid.getSelectionModel().getSelectedItem();
if(be.getKeyCode() == KeyCodes.KEY_DELETE && !rowData.isRemoved()){
//delete
}
if(be.getKeyCode() == 107 && rowData.isRemoved()){// press the + key
//add
}
if(be.getKeyCode() >= 49 || be.getKeyCode() <= 90){
showStartWithDialog(grid.getStore(), (String)be.getValue());
}
}
});
and the other isse is :
listStore.getAt(i).getLName().toLowerCase().startsWith(startWithlname)); returns always FALSE
and i have a Info.Display for the 2 Strings and the getLName is "Adair" and startWithlname is "ad" or "ada" or "a" or even "adair"
I wanted to add to the listener that if the key pressed is a letter, then show a dialog. and the problems start...
1) when the last feature is added, I can't navigate with the arrows on my grid, and can't use the "del" and the "+" keys
2) when I press a key to show the dialog, the be.getValue() (witch is supposed to be the letter typed, is always empty string)
3) and finally when I try to use the startsWith() method, it doesn't work...
Here is my code in order:
the grid listener:
grid.addListener(Events.OnKeyDown, new Listener<GridEvent<PersInfo>>() {
@Override
public void handleEvent(GridEvent<PersInfo> be) {
PersInfo rowData = grid.getSelectionModel().getSelectedItem();
if(be.getKeyCode() == KeyCodes.KEY_DELETE && !rowData.isRemoved()){
//delete
}
if(be.getKeyCode() == 107 && rowData.isRemoved()){// press the + key
//add
}
if(be.getKeyCode() >= 49 || be.getKeyCode() <= 90){
showStartWithDialog(grid.getStore(), (String)be.getValue());
}
}
});
and the other isse is :
listStore.getAt(i).getLName().toLowerCase().startsWith(startWithlname)); returns always FALSE
and i have a Info.Display for the 2 Strings and the getLName is "Adair" and startWithlname is "ad" or "ada" or "a" or even "adair"