Ext js ----> grid

來源:互聯網
上載者:User

標籤:style   blog   http   color   io   os   ar   java   for   

<link href="../bootstrap32/css/bootstrap.min.css" rel="stylesheet" type="text/css" />

<link href="../font-awesome41/css/font-awesome.min.css" rel="stylesheet" type="text/css" />

<link href="../Extjs42/resources/css/ext-all-gray.css" rel="stylesheet" type="text/css" />
<script src="../Extjs42/bootstrap.js" type="text/javascript"></script>
<script src="../js/lib/jquery-1.7.1.js" type="text/javascript"></script>

 

    <script type="text/javascript">  

    var store,  ugrid;

 

     Ext.onReady(function(){

       //初始化Model

    Ext.regModel("Supplier", { fields: ["Id", "SupplierName", "Symbo", "ContactPerson", "FixedTelephone", "MoneyType", "Email"] });

      //載入資料

    store = new Ext.data.JsonStore({

  
      fields: ["Id", "SupplierName", "Symbo", "ContactPerson", "ContactPerson", "FixedTelephone", "MoneyType", "Email"],
     proxy: {
      type: ‘ajax‘,
      url: "SupplierSelect123.aspx?action=async",
      reader: {       
        type: "json", //返回JSON格式
        root: ‘rows‘, // 資料1
        totalProperty: ‘pageCount‘//資料2
      }
     },

      pageSize: 20,//分頁條件
      autoLoad: { start: 0, limit: 20 }
    });

    //grid

      ugrid = Ext.create(‘Ext.grid.Panel‘, {
        store: store,
        region: ‘center‘,
        margins: ‘90 0 0 0‘,
        columns: [
{ id: ‘Id‘, header: ‘Id‘, dataIndex: ‘Id‘, hidden: true },
{ id: ‘Symbo‘, dataIndex: ‘Symbo‘, header: ‘貨幣符號‘, hidden: true },
new Ext.grid.RowNumberer(),
{ id: ‘SupplierName‘, dataIndex: ‘SupplierName‘, header: ‘供應商名稱‘, width: 220 },
{ id: ‘ContactPerson‘, dataIndex: ‘ContactPerson‘, header: ‘連絡人‘, width: 70 },
{ id: ‘FixedTelephone‘, dataIndex: ‘FixedTelephone‘, header: ‘固定電話‘, width: 100 },
{ id: ‘MoneyType‘, dataIndex: ‘MoneyType‘, header: ‘交易幣種‘, width: 60 },
{ id: ‘Email‘, dataIndex: ‘Email‘, header: ‘Email‘, width: 150 }
],

//添加監聽事件    雙擊事件   itemdblclick
listeners: { ‘itemdblclick‘: function (e) {
var recs = ugrid.getSelectionModel().getSelection();
var Json;
if (!recs || recs <= 0) {
Ext.Msg.alert(‘提示‘, ‘請選擇相應的記錄!‘);
} else {
Json = { SupplierId: recs[0].get(‘Id‘), SupplierName: recs[0].get(‘SupplierName‘),
MoneyType: recs[0].get(‘MoneyType‘), Symbo: recs[0].get(‘Symbo‘)
};
}
window.returnValue = Json;
window.close();

}
},

//分頁
bbar: [{

xtype: ‘pagingtoolbar‘,
displayMsg: ‘顯示 {0} - {1} 條,共計 {2} 條‘,
emptyMsg: "沒有資料",
beforePageText: "當前頁",
afterPageText: "共{0}頁",
store: store,
displayInfo: true
}]
});

//布局

var viewport = new Ext.Viewport({
layout: ‘border‘,
items: [ugrid]
});

});

    </script>

 

 

 

後台

string json = "{\"pageCount\":" + PageCount.ToString() + ",\"rows\":" + str1+"}";
// JObject jo = new JObject();
//jo.Add("pageCount", PageCount.ToString());
Response.Write(json);
Response.End();

 

Ext js ----> grid

聯繫我們

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