Skip to main content

XML Table Grid In Ext GWT


XML Table Grid In Ext GWT Sample Code

  1. package com.extjs.gxt.samples.client.examples.grid;  
  2.   
  3. import java.util.ArrayList;  
  4. import java.util.List;  
  5.   
  6. import com.extjs.gxt.samples.client.Examples;  
  7. import com.extjs.gxt.samples.resources.client.Resources;  
  8. import com.extjs.gxt.ui.client.Style.HorizontalAlignment;  
  9. import com.extjs.gxt.ui.client.data.BaseListLoader;  
  10. import com.extjs.gxt.ui.client.data.HttpProxy;  
  11. import com.extjs.gxt.ui.client.data.ListLoadResult;  
  12. import com.extjs.gxt.ui.client.data.ModelData;  
  13. import com.extjs.gxt.ui.client.data.ModelType;  
  14. import com.extjs.gxt.ui.client.data.XmlLoadResultReader;  
  15. import com.extjs.gxt.ui.client.event.ButtonEvent;  
  16. import com.extjs.gxt.ui.client.event.SelectionListener;  
  17. import com.extjs.gxt.ui.client.store.ListStore;  
  18. import com.extjs.gxt.ui.client.widget.ContentPanel;  
  19. import com.extjs.gxt.ui.client.widget.LayoutContainer;  
  20. import com.extjs.gxt.ui.client.widget.button.Button;  
  21. import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;  
  22. import com.extjs.gxt.ui.client.widget.grid.ColumnModel;  
  23. import com.extjs.gxt.ui.client.widget.grid.Grid;  
  24. import com.extjs.gxt.ui.client.widget.layout.FitLayout;  
  25. import com.extjs.gxt.ui.client.widget.layout.FlowLayout;  
  26. import com.google.gwt.core.client.GWT;  
  27. import com.google.gwt.http.client.RequestBuilder;  
  28. import com.google.gwt.user.client.Element;  
  29.   
  30. public class XmlGridExample extends LayoutContainer {  
  31.   
  32.   @Override  
  33.   protected void onRender(Element parent, int index) {  
  34.     super.onRender(parent, index);  
  35.     setLayout(new FlowLayout(10));  
  36.   
  37.     List<ColumnConfig> columns = new ArrayList<ColumnConfig>();  
  38.     columns.add(new ColumnConfig("Sender""Sender"100));  
  39.     columns.add(new ColumnConfig("Email""Email"165));  
  40.     columns.add(new ColumnConfig("Phone""Phone"100));  
  41.     columns.add(new ColumnConfig("State""State"50));  
  42.     columns.add(new ColumnConfig("Zip""Zip Code"65));  
  43.   
  44.     // create the column model  
  45.     ColumnModel cm = new ColumnModel(columns);  
  46.   
  47.     // defines the xml structure  
  48.     ModelType type = new ModelType();  
  49.     type.setRoot("records");  
  50.     type.setRecordName("record");  
  51.     type.addField("Sender""Name");  
  52.     type.addField("Email");  
  53.     type.addField("Phone");  
  54.     type.addField("State");  
  55.     type.addField("Zip");  
  56.   
  57.     // Determine if Explorer or Example for XML path  
  58.     String path = GWT.getHostPageBaseURL() + (Examples.isExplorer() ? "" : "../../") + "data/data.xml";  
  59.   
  60.     // use a http proxy to get the data  
  61.     RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, path);  
  62.     HttpProxy<String> proxy = new HttpProxy<String>(builder);  
  63.   
  64.     // need a loader, proxy, and reader  
  65.     XmlLoadResultReader<ListLoadResult<ModelData>> reader = new XmlLoadResultReader<ListLoadResult<ModelData>>(type);  
  66.   
  67.     final BaseListLoader<ListLoadResult<ModelData>> loader = new BaseListLoader<ListLoadResult<ModelData>>(proxy,  
  68.         reader);  
  69.   
  70.     ListStore<ModelData> store = new ListStore<ModelData>(loader);  
  71.     final Grid<ModelData> grid = new Grid<ModelData>(store, cm);  
  72.     grid.setBorders(true);  
  73.     grid.setLoadMask(true);  
  74.     grid.getView().setEmptyText("Please hit the load button.");  
  75.     grid.setAutoExpandColumn("Sender");  
  76.   
  77.     ContentPanel panel = new ContentPanel();  
  78.     panel.setFrame(true);  
  79.     panel.setCollapsible(true);  
  80.     panel.setAnimCollapse(false);  
  81.     panel.setButtonAlign(HorizontalAlignment.CENTER);  
  82.     panel.setIcon(Resources.ICONS.table());  
  83.     panel.setHeading("XML Table Demo");  
  84.     panel.setLayout(new FitLayout());  
  85.     panel.add(grid);  
  86.     panel.setSize(575350);  
  87.   
  88.     // add buttons  
  89.     Button load = new Button("Load XML"new SelectionListener<ButtonEvent>() {  
  90.       public void componentSelected(ButtonEvent ce) {  
  91.         loader.load();  
  92.       }  
  93.     });  
  94.   
  95.     panel.addButton(load);  
  96.   
  97.     add(panel);  
  98.   
  99.   }  
  100.   
  101. }  

Comments

Popular posts from this blog

Gradle project sync failed. Basic functionality (e.g, editing, debugging) will not work properly.

Gradle is an open source build tool which help us to accelerate developer productivity. Go to Gradle Services website(http://services.gradle.org/distributions/) and download the latest version Download the latest version gradle-4.7-rc-1-all.zip ( Latest version while writing this article) and you can download greater than 4.7 if available and make sure the zip file contains "all" keyword (gradle-*.*-rc-*-all.zip). Go to your download location and unzip the downloaded file Android Studio > File >  Settings > Build, Execution, Deployment  Gradle Project-level settings -> Select Use local gradle distribution -> Select the unzip folder of downloaded gradle version -> Click OK button to exit from the Settings window. Please Wait until Gradle build completes and your problem have been resolved.   If gradle build failed, follow few more steps to get resolved Final step to resolve this error Go to your project -> Gradle script ->

What is GMMXlE (Google Doodle)?

In every celebration Google does something to their Logo to make it doodle but that could be easy to read Google name made it under that logo but this time they have made it Doodle for the new year Eve 2011 which is GMMXlE . This Doodle is a great brain teaser for all the people to find out what it is. What Is GMMXlE? The First G and Last E stands For Google Logo First Character and Last Character i.e GE( G oogl e ). And MMXl is a Roman Letter for 2011. Roman Letter Values For Appropriate Letters M Stands For 1000 X Stands For 10 l Stands For 1 Apply these values Under this Formula To Turn it Into 2011 MMXl 2MXl 2(1000)+(10)+1 2011 Finally It is GMMXlE-G2011E

Form Input Widget on Flutter Android - Text, Slider, Switch, Date Picker, Buttons & Check Box

  Learn how you can use the different Form Input Widget on Flutter Android - Text, Slider, Switch, Date Picker, Buttons & Check Box This Application will give a basic idea like how you can create different widgets for the form panel designing. Video Tutorial import 'package:flutter/material.dart'; import 'package:intl/intl.dart' as intl; class FormWidgetsDemo extends StatefulWidget { const FormWidgetsDemo({super.key}); @override State createState() => _FormWidgetsDemoState(); } class _FormWidgetsDemoState extends State { final _formKey = GlobalKey (); DateTime date = DateTime.now(); double maxValue = 0; bool? checkBoxFeature = false; bool sliderFeature = false; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Hakeem Innovation Technology'), ), body: Form( key: _formKey, child: Scrollbar( child: Align( ali