Skip to main content

Sponsored Project Grid In Ext GWT


Sponsored Project 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. import java.util.Map;  
  6.   
  7. import com.extjs.gxt.samples.resources.client.Resources;  
  8. import com.extjs.gxt.samples.resources.client.TestData;  
  9. import com.extjs.gxt.samples.resources.client.model.Task;  
  10. import com.extjs.gxt.ui.client.Style.HorizontalAlignment;  
  11. import com.extjs.gxt.ui.client.data.ModelData;  
  12. import com.extjs.gxt.ui.client.store.GroupingStore;  
  13. import com.extjs.gxt.ui.client.store.ListStore;  
  14. import com.extjs.gxt.ui.client.widget.ContentPanel;  
  15. import com.extjs.gxt.ui.client.widget.LayoutContainer;  
  16. import com.extjs.gxt.ui.client.widget.form.NumberField;  
  17. import com.extjs.gxt.ui.client.widget.grid.CellEditor;  
  18. import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;  
  19. import com.extjs.gxt.ui.client.widget.grid.ColumnData;  
  20. import com.extjs.gxt.ui.client.widget.grid.ColumnModel;  
  21. import com.extjs.gxt.ui.client.widget.grid.EditorGrid;  
  22. import com.extjs.gxt.ui.client.widget.grid.Grid;  
  23. import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;  
  24. import com.extjs.gxt.ui.client.widget.grid.GroupSummaryView;  
  25. import com.extjs.gxt.ui.client.widget.grid.SummaryColumnConfig;  
  26. import com.extjs.gxt.ui.client.widget.grid.SummaryRenderer;  
  27. import com.extjs.gxt.ui.client.widget.grid.SummaryType;  
  28. import com.extjs.gxt.ui.client.widget.layout.FitLayout;  
  29. import com.extjs.gxt.ui.client.widget.layout.FlowLayout;  
  30. import com.google.gwt.i18n.client.NumberFormat;  
  31. import com.google.gwt.user.client.Element;  
  32.   
  33. public class TotalsGridExample extends LayoutContainer {  
  34.   
  35.   @Override  
  36.   protected void onRender(Element parent, int index) {  
  37.     super.onRender(parent, index);  
  38.     setLayout(new FlowLayout(10));  
  39.   
  40.     List<Task> tasks = TestData.getTasks();  
  41.     GroupingStore<Task> store = new GroupingStore<Task>();  
  42.     store.groupBy("project");  
  43.     store.add(tasks);  
  44.   
  45.     List<ColumnConfig> columns = new ArrayList<ColumnConfig>();  
  46.   
  47.     SummaryColumnConfig<Integer> desc = new SummaryColumnConfig<Integer>("description""Task"65);  
  48.     desc.setSummaryType(SummaryType.COUNT);  
  49.     desc.setSummaryRenderer(new SummaryRenderer() {  
  50.       public String render(Number value, Map<String, Number> data) {  
  51.         return value.intValue() > 1 ? "(" + value.intValue() + " Tasks)" : "(1 Task)";  
  52.       }  
  53.     });  
  54.   
  55.     SummaryColumnConfig<Double> project = new SummaryColumnConfig<Double>("project""Project"55);  
  56.     SummaryColumnConfig<Double> due = new SummaryColumnConfig<Double>("due""Due Date"20);  
  57.   
  58.     SummaryColumnConfig<Double> estimate = new SummaryColumnConfig<Double>("estimate""Estimate"20);  
  59.     estimate.setRenderer(new GridCellRenderer<Task>() {  
  60.       public String render(Task model, String property, ColumnData config, int rowIndex, int colIndex,  
  61.           ListStore<Task> store, Grid<Task> grid) {  
  62.         return model.get(property) + " hours";  
  63.       }  
  64.     });  
  65.     estimate.setSummaryType(SummaryType.SUM);  
  66.     estimate.setSummaryRenderer(new SummaryRenderer() {  
  67.       public String render(Number value, Map<String, Number> data) {  
  68.         return value.intValue() + " hours";  
  69.       }  
  70.     });  
  71.     estimate.setEditor(new CellEditor(new NumberField()));  
  72.   
  73.     SummaryColumnConfig<Double> rate = new SummaryColumnConfig<Double>("rate""Rate"20);  
  74.     rate.setNumberFormat(NumberFormat.getCurrencyFormat());  
  75.     rate.setSummaryFormat(NumberFormat.getCurrencyFormat());  
  76.     rate.setSummaryType(SummaryType.AVG);  
  77.     rate.setAlignment(HorizontalAlignment.RIGHT);  
  78.   
  79.     NumberField nf = new NumberField();  
  80.     nf.setAutoValidate(true);  
  81.     CellEditor ce = new CellEditor(nf);  
  82.     ce.setCancelOnEsc(true);  
  83.     rate.setEditor(ce);  
  84.   
  85.     SummaryColumnConfig<Double> cost = new SummaryColumnConfig<Double>("cost""Cost"20);  
  86.     cost.setSummaryFormat(NumberFormat.getCurrencyFormat());  
  87.     cost.setSummaryType(new SummaryType<Double>() {  
  88.       @Override  
  89.       public Double render(Object v, ModelData m, String field, Map<String, Object> data) {  
  90.         if (v == null) {  
  91.           v = 0d;  
  92.         }  
  93.         Task task = (Task) m;  
  94.         return ((Double) v).doubleValue() + (task.getEstimate() * task.getRate());  
  95.       }  
  96.   
  97.     });  
  98.     cost.setAlignment(HorizontalAlignment.RIGHT);  
  99.     cost.setRenderer(new GridCellRenderer<Task>() {  
  100.       public String render(Task model, String property, ColumnData config, int rowIndex, int colIndex,  
  101.           ListStore<Task> store, Grid<Task> grid) {  
  102.         Task task = (Task) model;  
  103.         return NumberFormat.getCurrencyFormat().format(task.getRate() * task.getEstimate());  
  104.       }  
  105.     });  
  106.   
  107.     columns.add(desc);  
  108.     columns.add(project);  
  109.     columns.add(due);  
  110.     columns.add(estimate);  
  111.     columns.add(rate);  
  112.     columns.add(cost);  
  113.     ColumnModel cm = new ColumnModel(columns);  
  114.   
  115.     GroupSummaryView summary = new GroupSummaryView();  
  116.     summary.setForceFit(true);  
  117.     summary.setShowGroupedColumn(false);  
  118.   
  119.     EditorGrid<Task> grid = new EditorGrid<Task>(store, cm);  
  120.     grid.setBorders(true);  
  121.     grid.setView(summary);  
  122.     grid.getView().setShowDirtyCells(false);  
  123.   
  124.     ContentPanel panel = new ContentPanel();  
  125.     panel.setHeading("Sponsored Projects");  
  126.     panel.setIcon(Resources.ICONS.table());  
  127.     panel.setCollapsible(true);  
  128.     panel.setFrame(true);  
  129.     panel.setSize(800450);  
  130.     panel.setLayout(new FitLayout());  
  131.     panel.add(grid);  
  132.     add(panel);  
  133.   }  
  134.   
  135. }  

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