Hello!
I am still evaluating (and liking) SmartGWT EE, and tried the mass saving example in a bit of a different context. I created my own little data source, and wrapped the particular grid in a Composite extending class (code below), to make it a widget.
The problem is, that if i want to add this Widget to, say, a tab in a tabset, it gets drawn twice: first when i call the constructor of my widget, and second when I add it to the tab.
Why is this the case? I call initWidget because I have to right? It seems that if i remove that it doesn't draw immediatly, but that screws up different things.
Help much appreciated!
I am still evaluating (and liking) SmartGWT EE, and tried the mass saving example in a bit of a different context. I created my own little data source, and wrapped the particular grid in a Composite extending class (code below), to make it a widget.
The problem is, that if i want to add this Widget to, say, a tab in a tabset, it gets drawn twice: first when i call the constructor of my widget, and second when I add it to the tab.
Why is this the case? I call initWidget because I have to right? It seems that if i remove that it doesn't draw immediatly, but that screws up different things.
Help much appreciated!
Code:
/** * This view shows data in a grid like fashion, based on ListGrid, from smartGWT library. * It is an overview, showing multiple entries. */ public class TaskRichTableView extends Composite { protected DataSource dataSource = DataSource.get("Task"); Layout layout = new VLayout(15); final ListGrid grid = new ListGrid(); //set all attributes ListGridField idField = new ListGridField("id", "id"); ListGridField descriptionField = new ListGridField("description", "description"); ListGridField deadlineField = new ListGridField("deadline", "deadline"); public TaskRichTableView() { this.init(); initWidget(layout); } public void init() { layout.setAutoHeight(); layout.setWidth100(); layout.setHeight100(); grid.setWidth100(); grid.setHeight100(); grid.setAlternateRecordStyles(true); grid.setCellHeight(22); grid.setDataSource(dataSource); grid.setFields(idField, descriptionField, deadlineField ); grid.setAutoFetchData(true); grid.setCanEdit(true); grid.setModalEditing(true); grid.setEditEvent(ListGridEditEvent.CLICK); grid.setListEndEditAction(RowEndEditAction.NEXT); grid.setAutoSaveEdits(false); layout.addMember(grid); HLayout hLayout = new HLayout(15); IButton editButton = new IButton("New Item"); editButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { grid.startEditingNew(); } }); hLayout.addMember(editButton); IButton saveButton = new IButton("Save"); saveButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { grid.saveAllEdits(); } }); hLayout.addMember(saveButton); IButton discardButton = new IButton("Discard Changes"); discardButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { grid.discardAllEdits(); } }); hLayout.addMember(discardButton); layout.addMember(hLayout); } }
Comment