如何用ext建立字顯示年和月的組件

來源:互聯網
上載者:User

     在做項目中,看到用ext做的時間控制項,只顯示年月。

    js代碼:

var combSpField=[{
  name:"id",
  mapping:"id"
 },{
  name:"value",
  mapping:"value"
 }];
 var combStore=new Ext.data.JsonStore({
  url:basePath + "/tenceKip.sdo",
  baseParams :{
   cmd:"    "
  },
  root:"date",
  fields : combSpField
 });
 combStore.load();
     opTimeListComb = new Ext.form.ComboBox({
        store : combStore,
        displayField : "value",
        valueField : "id",
        typeAhead : true,
        editable : false,
        mode : "local",
        width : 90,
        triggerAction : "all",
        selectOnFocus : true,
        renderTo : "selectMonth",
        listeners : {
         "render" : function() {
          combStore.load({
           callback : function() {
            if (combStore.getTotalCount() > 0) {
             opTimeListComb
               .setValue(combStore
                 .getAt(0).data.id);
            }
           }
          });
         }
        }
       });
       var monthBox = new Ext.Panel({
          width : 171,
          autoHeight : true,
          border : false,
          items : [{
             contentEl : "monthBox",
             border : false
            }]
         });
       var monthWin = new Ext.Window({
          width : 190,
          autoHeight : true,
          plain : true,
          modal : true,
          closeAction : "hide",
          items : [monthBox]
         });

       
       Ext.get("opTimeA").on("click", function(e, t) {
          monthWin.show();
          monthWin.show().alignTo(t, "tl-bl?");
         });

       Ext.fly("monthCommit").on("click", function(e, t) {
          //需要執行的代碼

         });

  在頁面中需要加入以下代碼:

    <div id="monthBox" class="x-hide-display">
    <div id="selectMonth" style="float: left;"></div>
    <div>
     <button id="monthCommit" type="submit" style="margin-left: 80px;float:left;">
      確定
     </button>
    </div>
    <div style="clear: both"></div>
   </div>

   由於ext只有顯示年月日的代碼,這樣就可以只保證顯示年月的。

 

 

聯繫我們

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