/* * SmartGWT (GWT for SmartClient) * Copyright 2008 and beyond, Isomorphic Software, Inc. * * SmartGWT 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. SmartGWT 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.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.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.grid.events.RecordDoubleClickEvent; import com.smartgwt.client.widgets.grid.events.RecordDoubleClickHandler; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.sample.showcase.client.data.ItemSupplyXmlDS; public class NestedFormSample implements EntryPoint { private ListGridRecord lastOpenedRecord; public void onModuleLoad() { VLayout layout = new VLayout(20); final ItemSupplyXmlDS itemSupplyXmlDS = ItemSupplyXmlDS.getInstance(); final ListGrid itemGrid = new ListGrid(); itemGrid.setWidth(600); itemGrid.setHeight(400); itemGrid.setDataSource(itemSupplyXmlDS); itemGrid.setAlternateRecordStyles(true); itemGrid.setUseAllDataSourceFields(true); itemGrid.addRecordDoubleClickHandler(new RecordDoubleClickHandler() { public void onRecordDoubleClick(RecordDoubleClickEvent event) { showFormEditor(itemGrid); } }); itemGrid.fetchData(); layout.addMember(itemGrid); IButton showDetail = new IButton("Show Embedded Form"); showDetail.setWidth(140); showDetail.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { showFormEditor(itemGrid); } }); layout.addMember(showDetail); IButton hideDetail = new IButton("Hide Embedded Form"); hideDetail.setWidth(140); hideDetail.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (lastOpenedRecord != null) { itemGrid.closeRecord(lastOpenedRecord); lastOpenedRecord = null; } } }); layout.addMember(hideDetail); layout.draw(); } private void showFormEditor(ListGrid itemGrid) { ListGridRecord record = itemGrid.getSelectedRecord(); if (record != null) { itemGrid.openRecordEditor(record); lastOpenedRecord = record; } } }