-->

GWT CellTable CheckboxCell Not working in IE8

2019-01-12 12:10发布

问题:

I am having a CellTable with CheckboxCell in it.

I have added the following handler to it:

private static Column<AIDataRecord, Boolean> m_checkColumn = 
    new Column<AIDataRecord, Boolean>(new CheckboxCell(true, false)) 
    {
        @Override
        public Boolean getValue(AIDataRecord object) 
        {
            // Get the value from the selection model.
            return object.isSelected();
        }   
        @Override
        public void onBrowserEvent(Context context, Element elem, AIDataRecord object, NativeEvent event) 
        {
            System.out.println("Browser Event Called");
            super.onBrowserEvent(context, elem, object, event); 
            String eventType = event.getType();
            if ("change".equals(eventType)) 
            {
                System.out.println("Value changed");
                object.toggleSelection();
                System.out.println("Nw : "+object.isSelected());
            }
        }
    };

where object.toggleSelection() is a method which reverses a boolean field i.e. true to false and false to true.

I am using this code find if any check box is selected or not to identify any row.

This thing is working perfectly fine in All major browsers Except IE 8.

In IE 8 I get the object.isSelected() true but still when I click on button on that panel to delete row, it shows isSelected() false for the same row.

Can any body please help me with where should I try to find the problem ? Why IE is behaving differently??

Can any Java/GWT expert please help me out...

Thanks.

回答1:

Why don't you assign a FieldUpdater to your your column? It is much simpler. For example:

m_checkColumn.setFieldUpdater(

    new FieldUpdater<AIDataRecord, Boolean>() {
         @Override
         public void update(int index, AIDataRecord object, Boolean value) {
            object.toggleSelection();
            Window.alert("Nw : " + object.isSelected());
         }
    }

);