Skip to main content

Live Grid In Ext GWT

Live 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.Date;  
  5. import java.util.List;  
  6.   
  7. import com.extjs.gxt.samples.resources.client.Resources;  
  8. import com.extjs.gxt.ui.client.Style.SortDir;  
  9. import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;  
  10. import com.extjs.gxt.ui.client.data.BasePagingLoader;  
  11. import com.extjs.gxt.ui.client.data.DataField;  
  12. import com.extjs.gxt.ui.client.data.JsonPagingLoadResultReader;  
  13. import com.extjs.gxt.ui.client.data.LoadEvent;  
  14. import com.extjs.gxt.ui.client.data.Loader;  
  15. import com.extjs.gxt.ui.client.data.ModelData;  
  16. import com.extjs.gxt.ui.client.data.ModelType;  
  17. import com.extjs.gxt.ui.client.data.PagingLoadResult;  
  18. import com.extjs.gxt.ui.client.data.PagingLoader;  
  19. import com.extjs.gxt.ui.client.data.ScriptTagProxy;  
  20. import com.extjs.gxt.ui.client.event.Listener;  
  21. import com.extjs.gxt.ui.client.store.ListStore;  
  22. import com.extjs.gxt.ui.client.widget.ContentPanel;  
  23. import com.extjs.gxt.ui.client.widget.LayoutContainer;  
  24. import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;  
  25. import com.extjs.gxt.ui.client.widget.grid.ColumnData;  
  26. import com.extjs.gxt.ui.client.widget.grid.ColumnModel;  
  27. import com.extjs.gxt.ui.client.widget.grid.Grid;  
  28. import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;  
  29. import com.extjs.gxt.ui.client.widget.grid.LiveGridView;  
  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.FillToolItem;  
  33. import com.extjs.gxt.ui.client.widget.toolbar.LiveToolItem;  
  34. import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;  
  35. import com.google.gwt.user.client.Element;  
  36.   
  37. public class LiveGridExample extends LayoutContainer {  
  38.   
  39.   @Override  
  40.   protected void onRender(Element parent, int index) {  
  41.     super.onRender(parent, index);  
  42.   
  43.     FlowLayout layout = new FlowLayout(10);  
  44.     setLayout(layout);  
  45.   
  46.     String url = "http://www.extjs.com/forum/topics-browse-remote.php";  
  47.     ScriptTagProxy<PagingLoadResult<ModelData>> proxy = new ScriptTagProxy<PagingLoadResult<ModelData>>(url);  
  48.   
  49.     ModelType type = new ModelType();  
  50.     type.setRoot("topics");  
  51.     type.setTotalName("totalCount");  
  52.     type.addField("title");  
  53.     type.addField("forumtitle");  
  54.     type.addField("forumid");  
  55.     type.addField("author");  
  56.     type.addField("replycount");  
  57.     type.addField("lastposter");  
  58.     type.addField("excerpt");  
  59.     type.addField("replycount");  
  60.     type.addField("threadid");  
  61.   
  62.     DataField datefield = new DataField("lastpost");  
  63.     datefield.setType(Date.class);  
  64.     datefield.setFormat("timestamp");  
  65.     type.addField(datefield);  
  66.   
  67.     JsonPagingLoadResultReader<PagingLoadResult<ModelData>> reader = new JsonPagingLoadResultReader<PagingLoadResult<ModelData>>(  
  68.         type);  
  69.   
  70.     final PagingLoader<PagingLoadResult<ModelData>> loader = new BasePagingLoader<PagingLoadResult<ModelData>>(proxy,  
  71.         reader);  
  72.   
  73.     loader.addListener(Loader.BeforeLoad, new Listener<LoadEvent>() {  
  74.       public void handleEvent(LoadEvent be) {  
  75.         BasePagingLoadConfig m = be.<BasePagingLoadConfig> getConfig();  
  76.         m.set("start", m.get("offset"));  
  77.         m.set("ext""js");  
  78.         m.set("lightWeight"true);  
  79.         m.set("sort", (m.get("sortField") == null) ? "" : m.get("sortField"));  
  80.         m.set("dir", (m.get("sortDir") == null || (m.get("sortDir") != null && m.<SortDir> get("sortDir").equals(  
  81.             SortDir.NONE))) ? "" : m.get("sortDir"));  
  82.   
  83.       }  
  84.     });  
  85.     loader.setSortDir(SortDir.DESC);  
  86.     loader.setSortField("lastpost");  
  87.   
  88.     loader.setRemoteSort(true);  
  89.   
  90.     ListStore<ModelData> store = new ListStore<ModelData>(loader);  
  91.   
  92.     List<ColumnConfig> columns = new ArrayList<ColumnConfig>();  
  93.   
  94.     ColumnConfig title = new ColumnConfig("title""Topic"100);  
  95.     title.setRenderer(new GridCellRenderer<ModelData>() {  
  96.   
  97.       public Object render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex,  
  98.           ListStore<ModelData> store, Grid<ModelData> grid) {  
  99.         return "<b><a style=\"color: #385F95; text-decoration: none;\" href=\"http://extjs.com/forum/showthread.php?t="  
  100.             + model.get("threadid")  
  101.             + "\" target=\"_blank\">"  
  102.             + model.get("title")  
  103.             + "</a></b><br /><a style=\"color: #385F95; text-decoration: none;\" href=\"http://extjs.com/forum/forumdisplay.php?f="  
  104.             + model.get("forumid") + "\" target=\"_blank\">" + model.get("forumtitle") + " Forum</a>";  
  105.       }  
  106.   
  107.     });  
  108.     columns.add(title);  
  109.     columns.add(new ColumnConfig("replycount""Replies"50));  
  110.   
  111.     ColumnConfig last = new ColumnConfig("lastpost""Last Post"200);  
  112.     last.setRenderer(new GridCellRenderer<ModelData>() {  
  113.   
  114.       public Object render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex,  
  115.           ListStore<ModelData> store, Grid<ModelData> grid) {  
  116.         return model.get("lastpost") + "<br/>by " + model.get("lastposter");  
  117.       }  
  118.   
  119.     });  
  120.     columns.add(last);  
  121.   
  122.     ColumnModel cm = new ColumnModel(columns);  
  123.   
  124.     final Grid<ModelData> grid = new Grid<ModelData>(store, cm);  
  125.     grid.setBorders(true);  
  126.     grid.setAutoExpandColumn("title");  
  127.     grid.setLoadMask(true);  
  128.     grid.setStripeRows(true);  
  129.   
  130.     LiveGridView liveView = new LiveGridView();  
  131.     liveView.setEmptyText("No rows available on the server.");  
  132.     liveView.setRowHeight(32);  
  133.     grid.setView(liveView);  
  134.   
  135.     ContentPanel panel = new ContentPanel();  
  136.     panel.setFrame(true);  
  137.     panel.setCollapsible(true);  
  138.     panel.setAnimCollapse(false);  
  139.     panel.setIcon(Resources.ICONS.table());  
  140.     panel.setHeading("LiveGrid Grid");  
  141.     panel.setLayout(new FitLayout());  
  142.     panel.add(grid);  
  143.     panel.setSize(600350);  
  144.     grid.getAriaSupport().setLabelledBy(panel.getHeader().getId() + "-label");  
  145.       
  146.     ToolBar toolBar = new ToolBar();  
  147.     toolBar.add(new FillToolItem());  
  148.   
  149.     LiveToolItem item = new LiveToolItem();  
  150.     item.bindGrid(grid);  
  151.   
  152.     toolBar.add(item);  
  153.     panel.setBottomComponent(toolBar);  
  154.   
  155.     add(panel);  
  156.   
  157.   }  
  158.   
  159. }  

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