Code for one-time Data Reading by Ext. Data. pagingmemoryproxy

Source: Internet
Author: User

1. Create get. php
Get. php => CopyCode The Code is as follows: <? PHP
$ DATA = array (
Array (1, "Yixing", 123 ),
Array (2, "chenlin", 13 ),
Array (3, "Lixin", 123 ),
Array (4, "liumei", 344 ),
Array (5, "qiuye", 343 ),
Array (6, "Zhangli", 231 ),
Array (7, "Chenggong", 1234 ),
Array (9, "linmei", 123 ),
Array (10, "gaoxin", 234 ),
Array (11, "ximi", 1234 ),
Array (12, "suoming", 1234)
);
Echo json_encode ($ data );
?>

2. Search for pagingmemoryproxy. js in the downloaded extjs file and put it in a folder with get. php.
3. Create a grid.html File
Grid.html => Copy code The Code is as follows: <HTML>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = GBK">
<SCRIPT type = "text/JavaScript" src = "pagingmemoryproxy. js"> </SCRIPT>
<SCRIPT type = "text/JavaScript">
Ext. onready (function (){
Store = new Ext. Data. Store ({
Reader: New Ext. Data. arrayreader ({}, [// read the array to a metadata object
{Name: 'id '},
{Name: 'name '},
{Name: 'Password '}
])
});
Ext. Ajax. Request ({// read data transmitted from the background to the foreground
URL: 'Get. php ',
Method: 'get ',
Success: function (response, opts ){
VaR OBJ = ext. Decode (response. responsetext); // OBJ stores the response data
Store. Proxy = new Ext. Data. pagingmemoryproxy (OBJ), // pagingmemoryproxy () One-time read data
Store. Load ({Params: {start: 0, limit: 5}); // distribute by 5 Records
},
Failure: function () {Ext. msg. Alert ("failure ");}
});
VaR grid = new Ext. Grid. gridpanel ({
Store: store, // load store
Mode: 'remote ',
Width: 450,
Height: 200,
Applyto: 'grid ',
Frame: True,
Columns :[
{Header: "Number", width: 50, dataindex: 'id', sortable: true },
{Header: "name", width: 80, dataindex: 'name', sortable: true },
{Header: "password", width: 80, dataindex: 'Password', sortable: true}
],
Tbar: New Ext. pagingtoolbar ({// Toolbar
Pagesize: 5,
Store: store,
Displayinfo: True,
Displaymsg: 'From {0} to {1} records, all records are {2 }',
Emptymsg: "No records"
}),
Viewconfig :{
Forcefit: True
}
})
});
</SCRIPT>
</Head>
<Body>
<Div id = "Grid"> </div>
</Body>
</Html>

4. Create the file r01.js
R01.js => Copy code The Code is as follows: Ext. onready (function (){
Ext. quicktips. INIT ();
VaR root = new Ext. Tree. treenode ({
Text: 'simple tree ',
Expanded: True
})
VaR user = (New Ext. Tree. treenode ({
Text: 'user ',
Expanded: True
})
)
VaR user1 = new Ext. Tree. treenode ({
Text: 'user 1'
})
VaR user2 = new Ext. Tree. treenode ({
Text: 'user 2 ',
})
Root. appendchild (User );
User. appendchild (user1 );
User. appendchild (user2 );
// Create a root node
VaR tree = new Ext. Tree. treepanel ({
Width: 180,
Height: 300,
Root: Root
})
// Intermediate area
VaR tabpanel = new Ext. tabpanel ({
Region: 'center ',
Enabletabscroll: True,
Activetab: 0,
Margins: '5 5 5 5 ',
Items :[{
ID: 'homepage ',
Title: 'homepage ',
Autoscroll: True,
HTML: '<Div style = "position: absolute; top: 40%; left: 40%> Welcome to the Homepage! </Div>'
}]
});
Function treeclick (){
Tabpanel. Add ({
Title: 'users ',
ID: '1 ',
Activetab: 1,
Closable: True,
Autoload :{
URL: 'grid.html ',
Scripts: True
}
})
}
User1.on ("click", treeclick );
// Interface display
New Ext. viewport ({
Title: 'ext. viewport example ',
Layout: 'border ',
Items :[
{
Region: 'west ',
Layout: 'fit ',
Width: 200,
Collapsible: True,
Margins: '5 0 5 5 ',
Items: Tree
},{
Region: 'center ',
Width: 200,
Layout: 'fit ',
Margins: '5 0 5 5 ',
Items: tabpanel
}]
})
});

5. Create r01.php
R01.php =>Copy codeThe Code is as follows: <HTML>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = GBK">
<Title> insert title here </title>
<LINK rel = "stylesheet" type = "text/CSS" href = "http://www.cnblogs.com/ext/resources/css/ext-all.css"/>
<SCRIPT type = "text/JavaScript" src = "http://www.cnblogs.com/ext/adapter/ext/ext-base.js"> </SCRIPT>
<SCRIPT type = "text/JavaScript" src = "http://www.cnblogs.com/ext/ext-all.js"> </SCRIPT>
<SCRIPT type = "text/JavaScript" src = "r01.js"> </SCRIPT>
</Head>
<Body>
</Body>
</Html>

6. Enter http: // localhost/register_01/R01/r01.php in the browser.


7. Conclusion
Tree listening event: tree. On
Ext. Data. arrayreader reads the array to a metadata object

Copy code The Code is as follows: function (response, opts ){
VaR OBJ = ext. Decode (response. responsetext); // OBJ stores the response data
Store. Proxy = new Ext. Data. pagingmemoryproxy (OBJ), // pagingmemoryproxy () One-time read data
Store. Load ({Params: {start: 0, limit: 5}); // distribute by 5 Records
} // Basic paging Application

Ext. pagingtoolbar Basic Application
Extjs help documentation: http://www.extjs.com/deploy/dev/docs/

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.