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

Connect To JioFi Device Without Knowing The Passwords Using WPS

If someone in your home or your friends are using Jiofi device and he/she is not sharing the password with you then i am going to share you a simple trick, so you can easily connect to the jiofi router without the need of password and start using the unlimited internet.

This trick can be achieved using the WPS technology (Wi-Fi Protected Setup; originally, Wi-Fi Simple Config) is a network security standard to create a secure wireless home network.

Follow the steps to get the internet for free using the "WPS Push Button Method"
Go to your Wifi Settings in your smartphone device like Android Turn on your Wifi Click the option button and select the  "WPS push button" and you will be seeing the popup window like this below picture.
Now take your JioFi Device and in the right side, you will seeing the WPS button  Hold the WPS button for few moments and see the Jiofi display, so the wifi icon will blink. After few seconds, your smartphone device would have shared the Wifi…

Five More Indian Languages - Google Translate

Google Translate add 5 more indian language translation like Bengali, Gujarati, Kannada, Tamil and Telugu.Till Today Google Translation supports 63 languages. As a indian bloggger its a happy to announce that all indic languages sites and blogs become internationalized one. All indic bloggers and sites owners have to attach the google translate widgets to their sites so that the internationalized reader can realize the value of your blog and may be a chance of becoming the readers.



How to Add The Google Translate Widgets on Blog or Sites

Just Add the Below code to internationalized your blog or site

<div id="google_translate_element"></div><script>
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'en'
}, 'google_translate_element');
}
</script><script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

If you want to customize the Goog…

Samsung Android 6.0 Marshmallow Supported Devices

Android Marshmallow is finally available. List of Samsung Device that can be upgraded to Android 6.0 Marshmallow.


Samsung Galaxy S6 edge+ Samsung Galaxy Note5Samsung Galaxy A8Samsung Galaxy A7Samsung Galaxy S6 edgeSamsung Galaxy S6Samsung Galaxy Note 4Samsung Galaxy AlphaSamsung Galaxy S5