javascript代码实例教程-Beginner Course about ExtJS

发布时间:2019-01-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了javascript代码实例教程-Beginner Course about ExtJS脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
小宝典致力于为广大程序猿(媛)提供高品质的代码服务,请大家多多光顾小站,小宝典在此谢过。

Foreword

Fortunately, I met “ExtJS” in earlier afternoon, the feeling just like my encounter wITh “REST” Actually, at beginning, I had no idea about them, but when I got in touch with REST, I found it really suit my taste and oPEned an interesting gate for me. I hope ExtJS can be amusing enough for both me and you. What we need is passion, am I right?

(If you have any interest with my previous blog about REST, click here.)


What's ExtJS?

My journey with ExtJS below.

My helper is coming. GOOGLE, Yes.

ExtJS is an open source UI library, which based on JavaScript, as same as jQuery and EasyUI. Well,ExtJS is more like EasyUI, but EasyUI is a lightweight UI library, ExtJS is powerful than it.

Maybe you are guessing my style of this story. Attention, please. First, I PRefer to do a summary introduce about ExtJS. Then, I will offer some contrast between ExtJS and EasyUI.

_______________________(↓A definition From Wikipedia) ______________________

“Ext JS is a pure JavaScript application framework for building interactive web applications using techniques such as Ajax, DHTML and DOM scripting. ”

_______________________(↑A definition from Wikipedia) ______________________

ExtJS can supply an abundant UI component library, which could help us in web development. It is an independent Ajax framework from back-end technoLOGy. In many scenes, not only for the languages, i.e., .Net, Java, PHp; but also for the IDE Eclipse, Microsoft Visual Studio etc.

ExtJS can support by almost all of the popular browser, internet Explorer 6+, FireFox 1.5+ (PC& Mac) ,Safari 2+,opera 9+. Independent Software vendors(IBM, Adobe, Cisco, etc.) are applying it.

ExtJS is an object-oriented library, the basic class is “Component”, and some derived classes which inherited form “Component”. Below is class diagram.

javascript代码实例教程-Beginner Course about ExtJS

<"/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHA+PC9wPgo8cD5FehrKUyBvZmZlcnMgYSB1c2VyLWZyaWVuZGx5IGFuZCBpbnRlZ3JhdGVkIFVJIGNvbXBvbmVudHMgYW5kIGNvbnRyb2xzLiB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S48L3A+CjxwPkxldKGvcyBnbyBvbiB3aXROIG91ciAKcHJldmlvdXMgcHJvamVjdCwgdG8gc2hvdyB3ZWF0aGVyIHJlcG9ydCBvZiBTaGVuemhlbiBpbiBHcmlkIENvbnRyb2wuPC9wPgpGaXJzdGx5LCBJIHdvdWxkIHNob3cgeW91IHRoZSBmaW5hbCBlZmZlY3QsIGF3ZXNvbWUhPGJyPgoKPGltZyBzcmM9"/uploaDFile/Collfiles/20140630/20140630130829122.jpg" alt="/">

To make it, we need to define a Ext.data.Model. A model is just a collection of fields that represents a type of data. Let’s define a model that represents a “Weather”.
Ext.define('Weather', {     extend: 'Ext.data.Model',     fields: ['date', 'weatherIconUrl', 'weatherDesc', 'tempMinC', 'tempMaxC'],     validations: [{         type: 'length',         field: 'date',         min: 1     }, {         type: 'length',         field: 'weatherDesc',         min: 1     }, {         type: 'length',         field: 'tempMinC',         min: 1     }, {         type: 'length',         field: 'tempMaxC',         min: 1     }] }); 

Now we can create a new Store instance via the REST Proxy.

VAR store = Ext.create('Ext.data.Store', {         autoLoad: true,         autoSync: true,         model: 'Weather',         proxy: {             type: 'rest',             url: 'https://api.worldweatheronline.COM/free/v1/weather.ashx?q=Shenzhen&format=JSON&num_of_days=5&key=689ab058717194e693b1fc1012fdb857d6874547',             reader: {                 type: 'json',                 root: 'data.weather'             },             writer: {                 type: 'json'             }         }     }); 

This is our JSONdata, including some array, which is a liTTLe special.

"weather": [    {"date": "2014-06-25", "precipMM": "8.2", "tempMaxC": "32", "tempMaxF": "90", "tempMinC": "28", "tempMinF": "82", "weatherCode": "113",     "weatherDesc": [ {"value": "Sunny" } ],    "weatherIconUrl": [{"value": "http:////cdn.worldweatheronline.net//images//wsymbols01_png_64//wsymbol_0001_sunny.png" } ],    "winddir16Point": "SSW", "winddirdegree": "193", "winddirection": "SSW", "windspeedKmph": "23", "windspeedMiles": "15" },   …  ]

At last is thegrid panel which columns contain dates.

var grid = Ext.create('Ext.grid.Panel', {         renderTo: document.body,         width: 650,         frame: true,         title: 'Weather Report of Shenzhen',         store: store,         iconCls: 'icon-user',         columns: [{             text: 'date',             sortable: true,             dataIndex: 'date',             field: {                 xtype: 'textfield'             }         }, {             header: 'weatherIconUrl',             width: 120,             sortable: false,             dataIndex: 'weatherIconUrl',             renderer: showIcon,// 'weatherIconUrl' is an array, so we need to render it respectively.             field: {                 xtype: 'textfield'             }         }, {             text: 'weatherDesc',             width: 200,             sortable: true,             dataIndex: 'weatherDesc',// 'weatherDesc' is an array, so we need to render it respectively.             renderer: showDesc,             field: {                 xtype: 'textfield'             }         }, {             text: 'tempMinC',             width: 100,             sortable: true,             dataIndex: 'tempMinC',             field: {                 xtype: 'textfield'             }         }, {             text: 'tempMaxC',             width: 100,             sortable: true,             dataIndex: 'tempMaxC',             field: {                 xtype: 'textfield'             }         }]     }); 

Because the data Index of “weatherIconUrl” and “weatherDesc” columns are arrays, so we need to render it respectively.

function showIcon(value) {     return 'Beginner Course about ExtJS'; } function showDesc(value) {     return value[0].value; } 

The End

Well, my journey is end. I am looking for a further or a new story with IT technology. How amusing!

觉得可用,就经常来吧! 脚本宝典 欢迎评论哦! js脚本,巧夺天工,精雕玉琢。小宝典献丑了!

脚本宝典总结

以上是脚本宝典为你收集整理的javascript代码实例教程-Beginner Course about ExtJS全部内容,希望文章能够帮你解决javascript代码实例教程-Beginner Course about ExtJS所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。