/* * 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.sql; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.data.Criteria; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.DSCallback; import com.smartgwt.client.data.DSRequest; import com.smartgwt.client.data.DSResponse; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler; import com.smartgwt.client.widgets.grid.events.SelectionEvent; import com.smartgwt.client.types.SelectionStyle; import com.smartgwt.client.widgets.layout.VLayout; import com.google.gwt.core.client.EntryPoint; public class ServerFormulaSample implements EntryPoint { @Override public void onModuleLoad() { ListGrid orderLineGrid = new ListGrid(); orderLineGrid.setDataSource(DataSource.get("OrderLine_FormulaField")); orderLineGrid.setWidth(700); orderLineGrid.setHeight(224); orderLineGrid.setAutoFetchData(false); orderLineGrid.setIsGroup(true); orderLineGrid.setGroupTitle("Items in Order #"); orderLineGrid.setShowAllColumns(true); ListGrid orderGrid = new ListGrid(); orderGrid.setDataSource(DataSource.get("Order_AggregatedField")); orderGrid.setWidth(700); orderGrid.setHeight(224); orderGrid.setAutoFetchData(false); orderGrid.setIsGroup(true); orderGrid.setGroupTitle("Orders showing total cost"); orderGrid.setShowAllColumns(true); orderGrid.setSelectionType(SelectionStyle.SINGLE); orderGrid.addSelectionChangedHandler(new SelectionChangedHandler() { @Override public void onSelectionChanged(SelectionEvent event) { String orderNumber = event.getSelectedRecord().getAttribute("orderNumber"); Criteria criteria = new Criteria(); criteria.addCriteria("orderNumber", orderNumber); orderLineGrid.fetchData(criteria); orderLineGrid.setGroupTitle("Items in Order #"+orderNumber); } }); VLayout vLayout = new VLayout(); vLayout.setHeight("100%"); vLayout.setWidth(500); vLayout.setMembersMargin(10); vLayout.addMembers(orderLineGrid, orderGrid); orderGrid.fetchData(null, new DSCallback() { @Override public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest) { orderGrid.selectRecord(0); } }); vLayout.draw(); } }