/* * Isomorphic SmartGWT web presentation layer * Copyright 2000 and beyond Isomorphic Software, Inc. * * OWNERSHIP NOTICE * Isomorphic Software owns and reserves all rights not expressly granted in this source code, * including all intellectual property rights to the structure, sequence, and format of this code * and to all designs, interfaces, algorithms, schema, protocols, and inventions expressed herein. * * If you have any questions, please email
. * * This entire comment must accompany any portion of Isomorphic Software source code that is * copied or moved from this file. */ package com.smartgwt.sample.showcase.client.dataintegration.java.transactions; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.rpc.RPCManager; import com.smartgwt.client.util.SC; 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.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.SelectItem; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.sample.showcase.client.PanelFactory; import com.smartgwt.sample.showcase.client.ShowcasePanel; import java.util.HashMap; import java.util.Map; public class QueuedMasterDetailAddSample implements EntryPoint { public void onModuleLoad() { DataSource queuedAddOrderDS = DataSource.get("queuedAdd_order"); DataSource queuedAddOrderItemDS = DataSource.get("queuedAdd_orderItem"); DataSource supplyCategoryDS = DataSource.get("supplyCategory"); DataSource supplyItemDS = DataSource.get("supplyItem"); final DynamicForm form = new DynamicForm(); form.setWidth(300); form.setDataSource(queuedAddOrderDS); form.setUseAllDataSourceFields(true); final ListGrid listGrid = new ListGrid(); listGrid.setHeight(224); listGrid.setWidth(400); listGrid.setDataSource(queuedAddOrderItemDS); listGrid.setCanEdit(true); listGrid.setAutoSaveEdits(false); ListGridField qtyField = new ListGridField("quantity", "Qty", 30); ListGridField categoryField = new ListGridField("categoryName", "Category"); SelectItem categorySelectItem = new SelectItem(); categorySelectItem.setOptionDataSource(supplyCategoryDS); categoryField.setEditorType(categorySelectItem); ListGridField itemField = new ListGridField("itemName", "Item"); SelectItem itemSelectItem = new SelectItem(); itemSelectItem.setOptionDataSource(supplyItemDS); itemField.setEditorType(itemSelectItem); listGrid.setFields(qtyField, categoryField, itemField); IButton addButton = new IButton("Add Order Line"); addButton.setWidth(110); addButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Map defaults = new HashMap(); defaults.put("quantity", 1); listGrid.startEditingNew(defaults); } }); IButton saveButton = new IButton("Save Order"); saveButton.setWidth(100); saveButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { RPCManager.startQueue(); form.saveData(); listGrid.saveAllEdits(); RPCManager.sendQueue(); form.editNewRecord(); listGrid.setData(null); SC.say("Order saved in single batch."); } }); HLayout hLayout = new HLayout(10); hLayout.addMember(addButton); hLayout.addMember(saveButton); VLayout layout = new VLayout(20); layout.addMember(form); layout.addMember(listGrid); layout.addMember(hLayout); layout.draw(); } }