Grid ! amostly a little incomplete! So i need help Gays!

public default void addTeacher(Grid grid) {
        Teacher teacher = null;
        TeacherImpl teacherImpl = new TeacherImpl();
        MList list = new MList();
        list = teacherImpl.getteacherList();
        grid.setSelectionMode(SelectionMode.NONE);
        grid.setEditorEnabled(true);
        for (Object obj : list.getList()) {
            teacher = (Teacher) obj;

            grid.addRow(teacher.getTf_tutor_id(), teacher.getTf_tutor_content(), teacher.getTf_tutor_ch(),
                    teacher.getTf_tutor_show(), teacher.getTf_tutor_hotrank());

        }
        TextField rankEditor = new TextField();
        rankEditor.addValidator(new RegexpValidator("^[0-9]
*[1-9]
[0-9]
*$", "Please enter a positive integer!"));
        grid.getColumn("ranking").setEditorField(rankEditor);
[size=4]
[font=tahoma]
[color=#ff0000]
        grid.getColumn("ID").setHidden(true);
[/color]
[/font]
[/size]
        grid.addShortcutListener(new ShortcutListener("ENTER", ShortcutAction.KeyCode.ENTER, null) {
            private static final long serialVersionUID = -5750865238489191851L;

            @Override
            public void handleAction(Object sender, Object target) {

                Object targetParent = ((AbstractComponent) target).getParent();
                if ((targetParent != null) && (targetParent instanceof Grid)) {
                    Grid targetGrid = (Grid) targetParent;

                    if (targetGrid.isEditorActive()) {
                        try {
                            targetGrid.saveEditor();
                            targetGrid.cancelEditor();
                        } catch (CommitException e) {
                            Notification.show("Validation failed");
                        }
                    }
                }
            }
        });
        // save;
        FieldGroup fieldGroup = new FieldGroup();
        grid.setEditorFieldGroup(fieldGroup);
        fieldGroup.addCommitHandler(new CommitHandler() {
            private static final long serialVersionUID = -8378742499490422335L;

            @Override
            public void preCommit(CommitEvent commitEvent) throws CommitException {

                //
            }

            @Override
            public void postCommit(CommitEvent commitEvent) throws CommitException {
                Item itemDataSource = fieldGroup.getItemDataSource();

                if (null == (Integer) itemDataSource.getItemProperty("ranking").getValue()
                        || "" == itemDataSource.getItemProperty("ranking").getValue()) {
                    Page.getCurrent().setUriFragment("!privilegelist");
                    Page.getCurrent().setUriFragment("!teacherrank");
                    Notification.show("League cannot be empty!");
                } else if ((Integer) itemDataSource.getItemProperty("ranking").getValue() <= 0) {

                    Page.getCurrent().setUriFragment("!privilegelist");
                    Page.getCurrent().setUriFragment("!teacherrank");
                    Notification.show("Please enter a positive integer!");
                } else {
                    teacherImpl.query((Integer) itemDataSource.getItemProperty("ID").getValue());
                    teacherImpl.updateteacher((Integer) itemDataSource.getItemProperty("ID").getValue(),
                            (Integer) itemDataSource.getItemProperty("ranking").getValue());

                    grid.setStyleName("stutable");
                    Page.getCurrent().setUriFragment("!privilegelist");
                    Page.getCurrent().setUriFragment("!teacherrank");
                    Notification.show("Saved successfully");
                }

            }
        });
    }


BUT it fails。 I don’t know the reason!
Debug shows


line 7 grid.setEditorEnabled(true);
is wrong

[b]

[/b]


THANKS!

Bes

t wis

h

es…

What kind of error did you notice? Is it a syntax error in compilation or a runtime error?

Thank you sir,those codes are right …i post too quikly. The reason why i was wrong is that i don’t set the comlumn( “grid1.addColumn(“ID”, Integer.class).setHidden(true);”) when the grid add column. In the other hand, can i set the column hidden
when the column has been added?

If the column was already added you could get it with
grig.getColumn(…)
and then invoke setHidden(true), as you have done earlier

Thank you very much sir。