EXTJS4.0.7开发积累(12)

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) {

var respText =Ext.JSON.decode(resp.responseText).dbs;

console.log('dbsNAME:'+eval(respText)[0].NAME);

console.log('dbsDB_ID:'+ eval(respText)[0].DB_ID);

}
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'}
]
comboboxselect事件取值方法

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'
gridcolumns设置

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 applyIfextjs中apply及applyIf方法都是用于把一个对象中的属性复制到另外一个对象的属性中,相当于属性拷贝。不同的是apply将会覆盖目标对象中的属性,而applyIf只拷贝目标对象中没有,而源对象中有的属性。
grid store修改/刷新为什么要使用apply方法呢?在grid定义里面就创建好store,然后在后面combobox的listener中,找到grid的store,执行store.add就可以了啊。如果要刷新store里面的记录,就先执行store.removeAll,然后再执行store.add操作便可以了啊……
store.eachcontactGroupStore.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'));
})
  
  
  
  
  
  
  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值