ExtJs基礎知識總結:彈窗(四)

來源:互聯網
上載者:User

標籤:tin   文字   ram   記錄   load   對話   cli   var   技術分享   

概述

  Extjs彈窗可以分為訊息彈窗、對話方塊,這些彈窗的方式ExtJs內建的Ext.Msg.alert就已經可以滿足簡單訊息提示,但是相對複雜的提示,比如如何將Ext.grid.Panel的控制項顯示嵌套到widget.window,然後隨著widget.window的show方法展示到頁面上哪?下面有幾種方案思路

思路一、直接將gridpandel填充到widget.window對應的Items

  代碼如下:

    var InvoiceItemGrid = Ext.create(‘Ext.grid.Panel‘, {                forceFit: false,        autoHeight: true,        autoScroll: true,        frame: true,        split: false,        layout: "fit",        height:document.documentElement.clientHeight,        margin: 0,        store: PrecStore,        loadMask: { msg: ‘資料載入中...‘ },        columnLines: true,        //dockedItems: [PTxtInfo],        //selType: "checkboxmodel",         selModel: {            mode: "multi",//multi,simple,single;預設為多選multi            checkOnly: false,//如果值為true,則只用點擊checkbox列才能選中此條記錄            allowDeselect: true,//如果值true,並且mode值為單選(single)時,可以通過點擊checkbox取消對其的選擇        },        viewConfig: {            stripeRows: true,//在表格中顯示斑馬線            enableTextSelection: true //可以複製儲存格文字 "GGXH", "XMSL", "XMDJ", "XMJE", "SL", "SE", "SPBM", "TaxItem"],        },        bbar: { xtype: "pagingtoolbar", inputItemWidth: 100, store: PrecStore, displayInfo: true },        columns: [           { text: "Id", width: 80, dataIndex: "Id", hidden: true },                     { text: "商品名稱", width: 80, dataIndex: "XMMC" },           { text: "單位", width: 80, dataIndex: "DW" },           { text: "規格型號", width: 120, dataIndex: "GGXH" },           { text: "數量", width: 80, dataIndex: "XMSL" },           { text: "項目單價", width: 120, dataIndex: "XMDJ" },           { text: "項目金額", width: 80, dataIndex: "XMJE" },           { text: "稅額", width: 80, dataIndex: "SE" },           { text: "稅率%", width: 80, dataIndex: "SL" },           { text: "稅目編碼", width: 160, dataIndex: "SPBM" },        ]    });    //主表單    var WindItem= Ext.create(‘widget.window‘, {        title: ‘發票明細‘,        closable: true,        closeAction: ‘hide‘,        modal: true,        frame: true,        layout: ‘fit‘,        width: 895,        minWidth: 895,        height: 430,        layout: {            type: ‘border‘,            padding: 2        },        items: [InvoiceItemGrid]    });

      顯示的結果如下:

      結果分析:grid的標題也沒顯示出來,而且隨著表單大小的展開,內容不會全部顯示。

思路二、直接將gridpandel填充到tabpanel的Items中,然後tabpanel放到widget.window對應的Items

      代碼如下:

    var WindItem= Ext.create(‘widget.window‘, {        title: ‘發票明細‘,        closable: true,        closeAction: ‘hide‘,        modal: true,        frame: true,        layout: ‘fit‘,        width: 895,        minWidth: 895,        height: 430,        layout: {            type: ‘border‘,            padding: 2        },        items: [{            region: ‘center‘,            xtype: ‘tabpanel‘,            items: InvoiceItemGrid        }]    });

      顯示的結果如下:

      結果分析:grid上面的那個藍色方塊,是A標籤。ExtJs中的tabpanel根據grid自動產生,顯然也不是最理想結果;

思路三、直接將gridpandel填充到From的Items中,然後From放到tabpanel的Items中,然後tabpanel放到widget.window對應的Items

      代碼如下:

var DataFrom = Ext.create(‘Ext.form.Panel‘, {        hidden: true,        bodyPadding: 0,        width: 890,        header: true,        layout: ‘fit‘,        defaults: {            anchor: ‘100%‘        },        defaultType: ‘textfield‘,        items: [            InvoiceItemGrid             ],        buttons: [{            text: ‘關閉‘,            handler: function () {                WindItem.close();            }        }]    });    var WindItem= Ext.create(‘widget.window‘, {        title: ‘發票明細‘,        closable: true,        closeAction: ‘hide‘,        modal: true,        frame: true,        layout: ‘fit‘,        width: 895,        minWidth: 895,        height: 430,        layout: {            type: ‘border‘,            padding: 2        },        items: [{            region: ‘center‘,            xtype: ‘tabpanel‘,            items: DataFrom        }]    });

      顯示的結果如下:

      結果分析:顯然這種方式相對更好點,思路3是根據思路2而來,思路2又是根據思路1而來,所以好的思路還是需要不斷最佳化和總結。

 

ExtJs基礎知識總結:彈窗(四)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.