Hello SmartGWT Friends.
I have a very strange thing going on. Throughout my app i use various ListGrid, which have myGrid.setCanEdit(true); and this all works (obviously :-) ).
One of them, though, is disabled (but shows the fetch data correctly!). It is a very very simple .ds.xml file and I just do not see what the problem is.
If I add a new record using a form that is displayed below the grid, that PARTICULAR new record IS ENABLED.
So why do I get the grid to be disabled? Must be something stupid probably... but still. Below is my code. It really is very simple.
Please look at the UserManagementWindow#initUserGrid() method to see how I initiated the grid. Any ideas why this happens?.
users.ds.xml
The view for showing the users.
I have a very strange thing going on. Throughout my app i use various ListGrid, which have myGrid.setCanEdit(true); and this all works (obviously :-) ).
One of them, though, is disabled (but shows the fetch data correctly!). It is a very very simple .ds.xml file and I just do not see what the problem is.
If I add a new record using a form that is displayed below the grid, that PARTICULAR new record IS ENABLED.
So why do I get the grid to be disabled? Must be something stupid probably... but still. Below is my code. It really is very simple.
Please look at the UserManagementWindow#initUserGrid() method to see how I initiated the grid. Any ideas why this happens?.
users.ds.xml
Code:
<?xml version="1.0" encoding="UTF-8"?> <DataSource ID="users" serverType="sql" tableName="users"> <fields> <field name="username" type="text" length="50" primaryKey="true" required="true" /> <field name="email" type="text" required="true"/> <field name="password" type="text" length="50"/> <field name="salt" type="hidden"/> <field name="enabled" type="boolean" required="false"/> </fields> </DataSource>
The view for showing the users.
Code:
public class UserManagementWindow extends Window { ListGrid users = new ListGrid(); DataSource usersDataSource = DataSource.get("users"); VLayout panel = new VLayout(); DynamicForm userForm = new DynamicForm(); public UserManagementWindow() { setShowModalMask(true); setModalMaskOpacity(100); centerInPage(); this.setWidth("80%"); this.setHeight("80%"); setShowCloseButton(true); setShowMinimizeButton(false); setIsModal(true); setAutoCenter(true); setAutoSize(true); setTitle("User Management"); panel.setAutoHeight(); panel.setWidth100(); panel.setHeight100(); initUsersGrid(); initNewUserForm(); panel.addMember(users); panel.addMember(userForm); this.addItem(panel); } public void initUsersGrid() { users.setAlternateRecordStyles(true); users.setCellHeight(22); users.setDataSource(usersDataSource); users.setAutoFetchData(false); users.setCanEdit(true); users.setEditEvent(ListGridEditEvent.DOUBLECLICK); users.setModalEditing(true); users.setShowFilterEditor(true); users.setDoubleClickDelay(100); users.setListEndEditAction(RowEndEditAction.NEXT); users.setCanRemoveRecords(true); users.setAutoSaveEdits(true); users.setWidth100(); users.setHeight(200); ListGridField userNameField = new ListGridField("username", "Gebruiker"); ListGridField enabledField = new ListGridField("enabled", "Account actief"); users.setFields(userNameField, enabledField); users.fetchData(); } public void initNewUserForm() { userForm.setDataSource(usersDataSource); TextItem username = new TextItem("username", "Username"); TextItem email = new TextItem("email", "Email"); SelectItem t = new SelectItem("thegroups", "Groepen"); t.setMultiple(true); t.setMultipleAppearance(MultipleAppearance.PICKLIST); DataSource gd = DataSource.get("groups_table"); t.setOptionDataSource(gd); t.setValueField("group_name"); t.setDisplayField("group_name"); ButtonItem submit = new ButtonItem("submit", "Gebruiker aanmaken"); submit .addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() { public void onClick( com.smartgwt.client.widgets.form.fields.events.ClickEvent event) { userForm.saveData(); } }); userForm.setFields(username, email, t, submit); } }
Comment