extjs的相關屬性

來源:互聯網
上載者:User

標籤:extjs

通用屬性:
    labelSeparator:''//表示fieldLabel後不會顯示冒號“:”    readOnly:true//唯讀    focusCls: 'txtHalfInput'//有焦點時的樣式    maxLength:3, enforceMaxLength:true//輸入位元check    fieldStyle: 'margin-top:3px;'//display上下不對齊解決辦法

Ext.button.Button

屬性:

enableToggle:true//設定按鈕為開關狀態pressed:true//開關沒被按下狀態disabled: true//使按鈕不可用,false可用

方法:

var pressed = Ext.getCmp('buttonGuard').pressed;//是否是被按下的狀態

Ext.form.field.Text

屬性:

    fieldStyle: 'ime-mode:disabled',//設定text的樣式    fieldCls: 'txtHalfInput',//設定text的class

方法:

        focus(true,600);//設定焦點,true表選中內容,false表只設焦點;600表頁面載入完畢0.6秒後執行

Ext.form.field.ComboBox

屬性:

    valueField:'ID'  //下拉裡的key值    displayField: 'NAME'//下拉裡顯示的內容    editable: false//false不可手動改值,true可以手動改    validator: function (v) {//表單項自訂check           return 'unvalidator';//返回true表示合法,否則為表單錯誤提示資訊    }


方法:

get/setRawValue//得到或設定combo所選值


Ext.form.NumberField

屬性:

hideTrigger: true,//不顯示控制項右邊的上下箭頭//實現焦點一離開後,1.00直接變成1Ext.form.GNumberField = Ext.extend(Ext.form.NumberField, {   setValue: function (v) {       v = typeof v == 'number' ? v : String(v).replace(this.decimalSeparator, ".");       v = isNaN(v) ? '' : String(v).replace(".", this.decimalSeparator);     //this.replaceDecimalVal(v);     //  if you want to ensure that the values being set on the field is also forced to the required number of decimal places.     // (not extensively tested)       v = isNaN(v) ? '' : this.fixPrecision(String(v).replace(".", this.decimalSeparator));       var ret = Ext.form.NumberField.superclass.setValue.call(this, v);       this.setRawValue(v);//沒有這句則控制項上不顯示1.00       return ret;   },   fixPrecision: function (value) {       var nan = isNaN(value);       if (!this.allowDecimals || this.decimalPrecision == -1 || nan || !value) {           return nan ? '' : value;       }       value = this.replaceDecimalVal(value);       return parseFloat(value).toFixed(this.decimalPrecision);   },  //防止四捨五入   replaceDecimalVal: function (v) {       var vArr = v.toString().split('.');       if (vArr.length > 1) {           if (vArr[1] > this.decimalPrecision) {               var dec = vArr[1].substring(0, this.decimalPrecision);               v = vArr[0] + '.' + dec;           }       }       return v;   }}


Ext.tree.Panel

屬性:

    rootVisible: true//顯示樹的根結點,false不顯示    collapsible: true//true可以點左箭頭摺疊,false不可摺疊    leaf: true//true表示是子結點,並且不能再有子結點    expanded: true//設定結點自動延伸    root: {//樹結點               text: '$',//結點顯示內容               expanded: true,//展開結點               children: [//子結點                   {                       text: '部門1',                       expanded: true,                       children: [                           { id: '1', text: 'power1', leaf: true }                       ]                   },                   { text: '部門2', expanded: true },                   {                       text: '部門3',                       expanded: true,                       children: [                           { text: 'power1', leaf: true },                           { text: 'power2', leaf: true },                           { text: 'power3', leaf: true }                       ]                   }               ]           }    listeners: {    itemclick: function (treePnl, record, item, index, e) {//樹結點的click事件    //record.data.root=true 表示該結點是根結點    //record.data.parentId = 'root' 表示該結點的父結點為根結點,也表示父結點的ID           if (!record.data.root && record.data.parentId != 'root') {               var parentText = record.parentNode.data.text;//父結點的顯示內容               var text = item.innerText;//當前結點的顯示內容               Ext.getCmp('displayPSTGroupName').setValue(parentText);               Ext.getCmp('displayPSTName').setValue(text);           } else {               Ext.getCmp('displayPSTGroupName').setValue('');               Ext.getCmp('displayPSTName').setValue('');           }    }    cellclick: function (view, e, columnIndex, rowItem) {    ?    ?    //view:        //e:        //columnIndex:所點列的索引,0開始        //rowItem: rowItem.data表示選中行的資料?    ?    }    }


方法:

    setNodeFocus(結點ID)//設定某結點為選中狀態    collapse()//讓整個樹摺疊起來    Ext.getCmp('treePnl').collapseAll();//收合所有的結點    Ext.getCmp('treePnl').getStore().getNodeById('root').expand();//展開根結點


Ext.GridStore

屬性:

    autoLoad: true//自動載入資料    dataFields:[{name:EVENT_ID}]//欄位名

方法:


var minGenTime = store.min('EVENT_GEN_TIME');//擷取欄位EVENT_GEN_TIME最小值var r = {};store.each(function (record) {//遍曆資料           if (record.get('EVENT_GEN_TIME') == minGenTime) {               r = record.raw;//擷取一條資料               return;           }});

事件:


beforeload:function(store, operation, options){}//資料載入前發生的事件datachanged:function(store, options){}//資料發生改變後發生的事件


Ext.grid.Panel

屬性:

    multiSelect: true//允許item項可以多選,false不可    selType: 'cellmodel'//表示點選cell,無該屬性則點選行    plugins: [Ext.create('Ext.grid.plugin.CellEditing', {clicksToEdit: 1})]//該屬性配合selType:'cellmodel'可實現編輯cell效果    columns:[new Ext.grid.RowNumberer({ width: 30, locked: false, header: " " })]//自動升番番號

方法:

    Ext.getCmp('gridEvent').getStore().removeAll();//清除grid裡的記錄    Ext.getCmp('grid').plugins[0].completeEdit();//當cellEditing時,編輯完不直接離開焦點而是直接點submit,此時會出現edit裡仍然是原值的情況,解決辦法是調一下completeEdit方法    treePnl.fireEvent('itemclick', treePnl, treePnl.getSelectionModel().getLastSelected());//觸發treeNode的單擊事件    //添加事件    Ext.getCmp('xxxxx').on('事件名', function(){})    //JS日期控制項要格式化日期後再往後台傳值    CREATE_TIME: !Ext.isEmpty() ? '' : Ext.util.Format.date(Ext.getCmp('datefieldLoginBegin').getValue(), 'Y/m/d')    //日期控制項check    Ext.getCmp('datefieldStartDate').isValid()    //tabPanel子項添加關閉事件    contentPanel.add({          id: nodeId,          title: nodeText,          closable: true,          header: false,           listeners: { 'beforedestroy': function () { callDestroy(nodeId); } },//添加tab項的關閉事件           html: '<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src= "' + node.attributes.actionPath + '"></iframe>'    });    //title置中    title: '資料總覽',    titleAlign: 'center',    style: 'text-align:center',    //解決雙擊treeNode後變成檔案夾    treeItemClick: function (treePnl, record, item, index, e) {            record.data.leaf = true;//在treeclick方法最後一行加上這句    },



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.