nijogeorgep / smartgwt

Automatically exported from code.google.com/p/smartgwt
0 stars 0 forks source link

ListGrid/Custom cell editors, tab key doesn't work with IE #689

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
http://www.smartclient.com/smartgwt/showcase/#grid_custom_editing_cell_new

Listgrid's Custom cell editors -feature works nicely with Firefox and Chrome. 
You can use tab key to navigate between grid rows. With IE tab key just loses 
focus from current editor.

Original issue reported on code.google.com by vra...@gmail.com on 2 Nov 2012 at 2:02

GoogleCodeExporter commented 8 years ago
Hi, I have the same problem and this problem is also with up and down arrows.

I'm using smartgwt 3.0 and internet explorer 10.0.9200

Original comment by dawstr1...@gmail.com on 12 Apr 2013 at 10:12

GoogleCodeExporter commented 8 years ago
I solved the problem using this tricky way:

onModuleLoad:
Event.addNativePreviewHandler(new NativePreviewHandler() {
    @Override
    public void onPreviewNativeEvent(NativePreviewEvent event) {
        if (event.getTypeInt() == Event.ONKEYDOWN) {            
            gridContainer.onPreviewKeyDown(event);
        }
    }
});

gridContainer:
public void onPreviewKeyDown(NativePreviewEvent event) {
    if (event.getNativeEvent().getShiftKey() && event.getNativeEvent().getKeyCode() == KeyCodes.KEY_TAB) {
        event.cancel();
        activatePreviousField();
        System.out.println("Shift+Tab");
    } else if (!event.getNativeEvent().getShiftKey() && event.getNativeEvent().getKeyCode() == KeyCodes.KEY_TAB) {
        event.cancel();
        activateNextField();
        System.out.println("Tab");
    }
}

public void activateNextField() {
    int selectedIndex = -1;
    if (grid.getSelectedRecord() != null) {
        selectedIndex = grid.getRecordIndex(grid.getSelectedRecord());
    }
    for (int i = 0; i < grid.getPropertiesCount(); i++) {
        selectedIndex = (selectedIndex + 1) % grid.getPropertiesCount();
        if (grid.canEditCell(selectedIndex, 1)) {
            grid.focus();
            grid.startEditing(selectedIndex, 1, false);
            return;
        }
    }
}

public void activatePreviousField() {
    int selectedIndex = -1;
    if (grid.getSelectedRecord() != null) {
        selectedIndex = grid.getRecordIndex(grid.getSelectedRecord());
    }
    for (int i = 0; i < grid.getPropertiesCount(); i++) {
        selectedIndex = (selectedIndex - 1 + grid.getPropertiesCount()) % grid.getPropertiesCount();
        if (grid.canEditCell(selectedIndex, 1)) {
            grid.focus();
            grid.startEditing(selectedIndex, 1, false);
            return;
        }
    }
}

I know it's terrible.. :)

Ville

Original comment by vra...@gmail.com on 12 Apr 2013 at 12:21

GoogleCodeExporter commented 8 years ago
Hey, thanks for your solution but I've checked it and still I cannot make the 
field editable. If I use startEditing and pass true as a last argument, the 
cell is in edit mode but I can't type anything in this field unless I click on 
that field.

Original comment by dawstr1...@gmail.com on 30 Apr 2013 at 9:35

GoogleCodeExporter commented 8 years ago
This was addressed Apr 14 for 3.0, 3.1 and 4.0.

Original comment by smartgwt...@gmail.com on 30 Apr 2013 at 2:12