Skip to main content

Paging Grid In Ext GWT

Paging 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.resources.client.Resources;  
  7. import com.extjs.gxt.samples.resources.client.TestData;  
  8. import com.extjs.gxt.samples.resources.client.model.Plant;  
  9. import com.extjs.gxt.ui.client.Style.HorizontalAlignment;  
  10. import com.extjs.gxt.ui.client.data.ModelData;  
  11. import com.extjs.gxt.ui.client.event.ButtonEvent;  
  12. import com.extjs.gxt.ui.client.event.SelectionListener;  
  13. import com.extjs.gxt.ui.client.store.ListStore;  
  14. import com.extjs.gxt.ui.client.util.DateWrapper;  
  15. import com.extjs.gxt.ui.client.widget.ContentPanel;  
  16. import com.extjs.gxt.ui.client.widget.LayoutContainer;  
  17. import com.extjs.gxt.ui.client.widget.button.Button;  
  18. import com.extjs.gxt.ui.client.widget.form.CheckBox;  
  19. import com.extjs.gxt.ui.client.widget.form.DateField;  
  20. import com.extjs.gxt.ui.client.widget.form.NumberField;  
  21. import com.extjs.gxt.ui.client.widget.form.SimpleComboBox;  
  22. import com.extjs.gxt.ui.client.widget.form.TextField;  
  23. import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;  
  24. import com.extjs.gxt.ui.client.widget.grid.CellEditor;  
  25. import com.extjs.gxt.ui.client.widget.grid.CheckColumnConfig;  
  26. import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;  
  27. import com.extjs.gxt.ui.client.widget.grid.ColumnModel;  
  28. import com.extjs.gxt.ui.client.widget.grid.Grid;  
  29. import com.extjs.gxt.ui.client.widget.grid.RowEditor;  
  30. import com.extjs.gxt.ui.client.widget.layout.FitLayout;  
  31. import com.extjs.gxt.ui.client.widget.layout.FlowLayout;  
  32. import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;  
  33. import com.google.gwt.i18n.client.DateTimeFormat;  
  34. import com.google.gwt.i18n.client.NumberFormat;  
  35. import com.google.gwt.user.client.Element;  
  36. public class RowEditorExample extends LayoutContainer {  
  37.   
  38.   @Override  
  39.   protected void onRender(Element parent, int index) {  
  40.     super.onRender(parent, index);  
  41.     setLayout(new FlowLayout(10));  
  42.   
  43.     List<ColumnConfig> configs = new ArrayList<ColumnConfig>();  
  44.   
  45.     ColumnConfig column = new ColumnConfig();  
  46.     column.setId("name");  
  47.     column.setHeader("Common Name");  
  48.     column.setWidth(220);  
  49.   
  50.     TextField<String> text = new TextField<String>();  
  51.     text.setAllowBlank(false);  
  52.     column.setEditor(new CellEditor(text));  
  53.     configs.add(column);  
  54.   
  55.     final SimpleComboBox<String> combo = new SimpleComboBox<String>();  
  56.     combo.setForceSelection(true);  
  57.     combo.setTriggerAction(TriggerAction.ALL);  
  58.     combo.add("Shade");  
  59.     combo.add("Mostly Shady");  
  60.     combo.add("Sun or Shade");  
  61.     combo.add("Mostly Sunny");  
  62.     combo.add("Sunny");  
  63.   
  64.     CellEditor editor = new CellEditor(combo) {  
  65.       @Override  
  66.       public Object preProcessValue(Object value) {  
  67.         if (value == null) {  
  68.           return value;  
  69.         }  
  70.         return combo.findModel(value.toString());  
  71.       }  
  72.   
  73.       @Override  
  74.       public Object postProcessValue(Object value) {  
  75.         if (value == null) {  
  76.           return value;  
  77.         }  
  78.         return ((ModelData) value).get("value");  
  79.       }  
  80.     };  
  81.   
  82.     column = new ColumnConfig();  
  83.     column.setId("light");  
  84.     column.setHeader("Light");  
  85.     column.setWidth(130);  
  86.     column.setEditor(editor);  
  87.     configs.add(column);  
  88.   
  89.     column = new ColumnConfig();  
  90.     column.setId("price");  
  91.     column.setHeader("Price");  
  92.     column.setAlignment(HorizontalAlignment.RIGHT);  
  93.     column.setWidth(70);  
  94.     column.setNumberFormat(NumberFormat.getCurrencyFormat());  
  95.     column.setEditor(new CellEditor(new NumberField()));  
  96.   
  97.     configs.add(column);  
  98.   
  99.     DateField dateField = new DateField();  
  100.     dateField.getPropertyEditor().setFormat(DateTimeFormat.getFormat("MM/dd/y"));  
  101.   
  102.     column = new ColumnConfig();  
  103.     column.setId("available");  
  104.     column.setHeader("Available");  
  105.     column.setWidth(95);  
  106.     column.setEditor(new CellEditor(dateField));  
  107.     column.setDateTimeFormat(DateTimeFormat.getFormat("MMM dd yyyy"));  
  108.     configs.add(column);  
  109.   
  110.     CheckColumnConfig checkColumn = new CheckColumnConfig("indoor""Indoor?"55);  
  111.     CellEditor checkBoxEditor = new CellEditor(new CheckBox());  
  112.     checkColumn.setEditor(checkBoxEditor);  
  113.     configs.add(checkColumn);  
  114.   
  115.     final ListStore<Plant> store = new ListStore<Plant>();  
  116.     store.add(TestData.getPlants());  
  117.   
  118.     ColumnModel cm = new ColumnModel(configs);  
  119.   
  120.     ContentPanel cp = new ContentPanel();  
  121.     cp.setIcon(Resources.ICONS.table());  
  122.     cp.setHeading("Edit Plants with RowEditor");  
  123.     cp.setFrame(true);  
  124.     cp.setSize(600300);  
  125.     cp.setLayout(new FitLayout());  
  126.   
  127.     final RowEditor<Plant> re = new RowEditor<Plant>();  
  128.     final Grid<Plant> grid = new Grid<Plant>(store, cm);  
  129.     grid.setAutoExpandColumn("name");  
  130.     grid.setBorders(true);  
  131.     grid.addPlugin(checkColumn);  
  132.     grid.addPlugin(re);  
  133.     grid.getAriaSupport().setLabelledBy(cp.getHeader().getId() + "-label");  
  134.     cp.add(grid);  
  135.   
  136.     ToolBar toolBar = new ToolBar();  
  137.     Button add = new Button("Add Plant");  
  138.     add.addSelectionListener(new SelectionListener<ButtonEvent>() {  
  139.   
  140.       @Override  
  141.       public void componentSelected(ButtonEvent ce) {  
  142.         Plant plant = new Plant();  
  143.         plant.setName("New Plant 1");  
  144.         plant.setLight("Mostly Shady");  
  145.         plant.setPrice(0);  
  146.         plant.setAvailable(new DateWrapper().clearTime().asDate());  
  147.         plant.setIndoor(false);  
  148.   
  149.         re.stopEditing(false);  
  150.         store.insert(plant, 0);  
  151.         re.startEditing(store.indexOf(plant), true);  
  152.   
  153.       }  
  154.   
  155.     });  
  156.     toolBar.add(add);  
  157.     cp.setTopComponent(toolBar);  
  158.     cp.setButtonAlign(HorizontalAlignment.CENTER);  
  159.     cp.addButton(new Button("Reset"new SelectionListener<ButtonEvent>() {  
  160.   
  161.       @Override  
  162.       public void componentSelected(ButtonEvent ce) {  
  163.         store.rejectChanges();  
  164.       }  
  165.     }));  
  166.   
  167.     cp.addButton(new Button("Save"new SelectionListener<ButtonEvent>() {  
  168.   
  169.       @Override  
  170.       public void componentSelected(ButtonEvent ce) {  
  171.         store.commitChanges();  
  172.       }  
  173.     }));  
  174.   
  175.     add(cp);  
  176.   }  
  177.   
  178. }  

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