/* * Smart GWT (GWT for SmartClient) * Copyright 2008 and beyond, Isomorphic Software, Inc. * * Smart GWT is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. Smart GWT is also * available under typical commercial license terms - see * http://smartclient.com/license * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ import com.smartgwt.client.data.DataSource; import com.smartgwt.client.types.Alignment; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.events.DrawEvent; import com.smartgwt.client.widgets.events.DrawHandler; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.sample.showcase.client.data.ItemSupplyXmlDS; import com.google.gwt.core.client.EntryPoint; public class GridRowExpansionEditorSample implements EntryPoint { public void onModuleLoad() { final DataSource dataSource = ItemSupplyXmlDS.getInstance(); final ListGrid listGrid = new ListGrid() { @Override protected Canvas getExpansionComponent(final ListGridRecord record) { final ListGrid grid = this; VLayout layout = new VLayout(5); layout.setPadding(5); final DynamicForm df = new DynamicForm(); df.setNumCols(4); df.setDataSource(dataSource); df.addDrawHandler(new DrawHandler() { public void onDraw(DrawEvent event) { df.editRecord(record); } }); IButton saveButton = new IButton("Save"); saveButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { df.saveData(); } }); IButton cancelButton = new IButton("Done"); cancelButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { grid.collapseRecord(record); } }); HLayout hLayout = new HLayout(10); hLayout.setAlign(Alignment.CENTER); hLayout.addMember(saveButton); hLayout.addMember(cancelButton); layout.addMember(df); layout.addMember(hLayout); return layout; } }; listGrid.setWidth(600); listGrid.setHeight(500); listGrid.setDrawAheadRatio(4); listGrid.setCanExpandRecords(true); listGrid.setAutoFetchData(true); listGrid.setDataSource(dataSource); ListGridField itemNameField = new ListGridField("itemName"); ListGridField skuField = new ListGridField("SKU"); listGrid.setFields(itemNameField, skuField); listGrid.draw(); } }