Ext js----> Grid

Source: Internet
Author: User

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

Initialize model

Ext.regmodel ("Supplier", {fields: ["Id", "SupplierName", "Symbo", "ContactPerson", "Fixedtelephone", "Moneytype", " Email "]});

Loading data

    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",//Return JSON format
Root: ' Rows ',//Data 1
Totalproperty: ' PageCount '//Data 2
}
},

pagesize:20,//Paging conditions
AutoLoad: {start:0, limit:20}
});

Grid

Ugrid = Ext.create (' Ext.grid.Panel ', {
STORE:STORE,
region: ' center ',
Margins: ' 0 0 0 ',
columns: [
{ID: ' id ', header: ' ID ', Datainde x: ' id ', hidden:true},
{id: ' Symbo ', dataindex: ' Symbo ', header: ' Currency symbol ', hidden:true},
New Ext.grid.RowNumber ER (),
{id: ' SupplierName ', dataindex: ' SupplierName ', header: ' Vendor name ', width:220},
{id: ' ContactPerson ', DataIn Dex: ' ContactPerson ', header: ' Contacts ', width:70},
{id: ' Fixedtelephone ', dataindex: ' Fixedtelephone ', header: ' Fixed phone ', WIDTH:100},
{id: ' Moneytype ', dataindex: ' Moneytype ', Header: ' Transaction currency ', width:60},
{id: ' Email ', dataindex: ' Em Ail ', header: ' Email ', width:150}
],

Add listener event Double-click event Itemdblclick
Listeners: {' Itemdblclick ': function (e) {
var RECs = Ugrid.getselectionmodel (). GetSelection ();
var Json;
if (!recs | | RECs <= 0) {
Ext.Msg.alert (' Hint ', ' please select the corresponding record! ‘);
} 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 ();

}
},

Page out
Bbar: [{

Xtype: ' Pagingtoolbar ',
Displaymsg: ' Show {0}-{1} bar, total {2} ',
Emptymsg: "No Data",
Beforepagetext: "Current Page",
Afterpagetext: "A total of {0} pages",
Store:store,
Displayinfo:true
}]
});

Layout

var viewport = new Ext.viewport ({
Layout: ' Border ',
Items: [Ugrid]
});

});

</script>

Background

String json = "{\" pagecount\ ":" + pagecount.tostring () + ", \" rows\ ":" + str1+ "}";
Jobject Jo = new Jobject ();
Jo. ADD ("PageCount", pagecount.tostring ());
Response.Write (JSON);
Response.End ();

Ext js----> Grid

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.