MVC embodiment of Ext. Grid. gridpanel

Source: Internet
Author: User

 

Extjs is an object-oriented feature used in the UI Layer of the J2EE framework, which is often attributed to the interface presentation layer.

In fact, extjs Ext. Grid. gridpanel is also an MVC Framework, which consists of four necessary components:
Store: The model holding the data records (rows) New Ext. Data. Store
Column Model: Column makeup new Ext. Grid. columnmodel
View: Encapsulates the user interface viewconfig
Selection Model: Selection behavior new Ext. Grid. rowselectionmodel

 

var grid = new Ext.grid.GridPanel({     store: new Ext.data.Store({         autoDestroy: true,         reader: reader,         data: xg.dummyData     }),     colModel: new Ext.grid.ColumnModel({         defaults: {             width: 120,             sortable: true         },         columns: [             {id: 'company', header: 'Company', width: 200, sortable: true, dataIndex: 'company'},             {header: 'Price', renderer: Ext.util.Format.usMoney, dataIndex: 'price'},             {header: 'Change', dataIndex: 'change'},             {header: '% Change', dataIndex: 'pctChange'},             // instead of specifying renderer: Ext.util.Format.dateRenderer('m/d/Y') use xtype             {                 header: 'Last Updated', width: 135, dataIndex: 'lastChange',                 xtype: 'datecolumn', format: 'M d, Y'             }         ]     }),     viewConfig: {         forceFit: true,  //Return CSS class to apply to rows depending upon data values         getRowClass: function(record, index) {             var c = record.get('change');             if (c < 0) {                 return 'price-fall';             } else if (c > 0) {                 return 'price-rise';             }         }     },     sm: new Ext.grid.RowSelectionModel({singleSelect:true}),     width: 600,     height: 300,     frame: true,     title: 'Framed with Row Selection and Horizontal Scrolling',     iconCls: 'icon-grid'}); 

 

Http://hi.baidu.com/jsjok/blog/item/8f12611b3b0d685f42a9ad4b.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.