EXTJS4.0.7开发积累
有从网络上搜索到的资源,也有自己开发中的总结,侵权告知删除!
Ext.MessageBox.alert | Ext.MessageBox.alert('Alert','An alert!');
Ext.Function.defer(function(){ Ext.MessageBox.hide(); }, 2000); Ext.MessageBox is asingleton, thus a ref is not necessary.
// Ext.MessageBox.hide.defer(100,this); // (function() { // Ext.MessageBox.hide(); // }).defer(2000); |
initComponent功用 | Within the definition of widget.gsip_categoriestabpanel you set items as a config. This means it will always reference the same object (and not the updated one). As first step, you should move the items definition to initComponent, there you can also console.log(i18n) to see it's the right one. |
ExtJS 4 - Never cachetree nodes in tree panel | I have a simpleExt.tree.Panel, which loads its data from a Ext.data.TreeStore using an ajaxproxy.
The default behaviorwhen expanding a treenode seems to be:
if expanded before:retrieve from cache if never expanded:retrieve from server How can I turn offthe caching option, so that it never caches (i.e. always retrieve from server)?
Put this as alistener in the store to get the desired behavior: collapse: function(node){ node.removeAll(); node.set("loaded", false); } |
what is _dc parameterin url [http://localhost/chart-rent/index.php/site/getlist?_dc=1300243558614] | _dc is a cache buster parameter. (dc - disable caching) GET requests are aggressively cached by the browser and by appending a unique timestamp it disables the browser cache. You can set the configuration noCache to false on the Proxy to turn this behavior off. (Or change the cacheString via the cacheString configuration) var store = new Ext.data.Store({ model: 'myModel', proxy: { type: 'server', url: ..some.url..., reader: 'json', noCache: false //this will allow browser to cache, thus removing _dc param } }); |
form.load | me.down('form').getForm().load({ url:'findByClusterId.action', params:{ id:me.cid } }); -------------------------------------------------------------------------------------------------------------------- myFormPanel.getForm().load({ url: '/getRoutingInfo.php', params: { consignmentRef: myConsignmentRef }, failure: function(form, action) { Ext.Msg.alert("Load failed", action.result.errorMessage); } }); a success response packet may look like this: { success: true, data: { clientName: "Fred. Olsen Lines", portOfLoading: "FXT", portOfDischarge: "OSL" } } while a failure response packet may look like this: { success: false, errorMessage: "Consignment reference not found" } |
解析如下字符串: {dbs:[{"DB_ID":1,"NAME":"default"}]} | success:function(resp,opts) { } |
combobox控件 | 展示定义: { xtype: 'combobox', fieldLabel: '表名称', itemId:'tbls_combobox', emptyText:'选择一张表……', displayField: 'name', width: 500, queryMode: 'local', listConfig: { getInnerTpl: function() { return '<div data-qtip="{name}. {slogan}">{name} ({abbr})</div>'; } } } Store创建和添加data: var tbls_store = Ext.create('Ext.data.Store', { fields: [ {type: 'string', name: 'tbl_name'}, {type: 'string', name: 'tbl_id'} ] }); for(var i in respText){ tbls_store.add({tbl_name:eval(respText)[i].TBL_NAME,tbl_id:eval(respText)[i].TBL_ID}); } console.info('tbls_store.count:'+tbls_store.count(false)); Ext.apply(me.getComponent('tbls_combobox').getStore(),tbls_store); console.info('store.size:'+me.getComponent('tbls_combobox').getStore().count(true)); fields内容可以灵活多样: fields: [ {type: 'string', name: 'tbl_name'}, {type: 'string', name: 'tbl_id'} ] |
combobox的select事件取值方法 | listeners:{ 'select':function(combo,records, eOpts){ console.log('selectinfo:'+records[0].get('tbl_id')); } } 未选择的时候,值为null,可以使用如下进行判断筛选:getValue()<=0 |
修改grid的行高 | 定义如下css: .x-grid3-row{ height:100px; } 在Grid的展示配置中添加: cls:'x-grid3-row' |
grid的columns设置 | columns : [ {text: "Record Name",flex: 1, align : 'center', dataIndex: 'name',sortable : false,menuDisabled:true,resizable:false}, {text: "column1",width: 70,align : 'center', dataIndex:'column1',sortable : false, menuDisabled:true,resizable:false}, {text: "column2",width: 70, align : 'center', dataIndex: 'column2',sortable : false,menuDisabled:true,resizable:false} ] |
apply vs applyIf | extjs中apply及applyIf方法都是用于把一个对象中的属性复制到另外一个对象的属性中,相当于属性拷贝。不同的是apply将会覆盖目标对象中的属性,而applyIf只拷贝目标对象中没有,而源对象中有的属性。 |
grid store修改/刷新 | 为什么要使用apply方法呢?在grid定义里面就创建好store,然后在后面combobox的listener中,找到grid的store,执行store.add就可以了啊。如果要刷新store里面的记录,就先执行store.removeAll,然后再执行store.add操作便可以了啊…… |
store.each | contactGroupStore.each(function(data){ if(value == data.raw.fzbh){ fzmc = data.raw.fzmc //退出循环 return false } }) 今天在遍历store时遇到的问题 当我在用store.each()遍历store用break退出时,报了个错误 unlabelled break must be inside loop or switch 在这里不能使用break,可以使用return false来代替 this.getStore().each(function (record) { console.info('queryboard hive_tbl_col_comment:'+record.get('hive_tbl_col_comment')); }) |