EXT learning-grid Paging

Source: Internet
Author: User
Gird data

The data on each page of the grid must be divided by the server side.

In this example, the server language is Php and the database is MySQL, which is used to export random data. The following script is used to obtain the data we want and the data is split into pages. The paging parameters are determined by the limit and start variables passed in by the page toolbar.

$ Link = mysql_pconnect ("test-db.vinylfox.com", "test", "testuser") or die ("cocould not connect"); mysql_select_db ("test ") or die ("cocould not select database"); $ SQL _count = "select ID, name, title, hire_date, active from random_employee_data"; $ SQL = $ SQL _count. "limit ". gird data

The data on each page of the grid must be divided by the server side.

In this example, the server language is Php and the database is MySQL, which is used to export random data. The following script is used to obtain the data we want and the data is split into pages. The paging parameters are determined by the limit and start variables passed in by the page toolbar.

___FCKpd___0

Because the development environment in each background is different, the server code here is not detailed.

How to Create a grid with pagination

In this exampleScripttagproxyThe reason is that the sample code and the server code are not on the same server (: "cross-origin"), and in most cases, the data is obtained on the same server, you can use httpproxy directly.

The only difference between datastore and datastore is that you need to setTotalproertyAttribute. In this example, we calculate the value of "Total" from the script on the server to tell datastore how many records there are in total. This indicates the number of all records.

    var ds = new Ext.data.Store({        proxy: new Ext.data.ScriptTagProxy({            url: 'http://www.vinylfox.com/yui-ext/examples/grid-paging/grid-paging-data.php'        }),        reader: new Ext.data.JsonReader({            root: 'results',            totalProperty: 'total',            id: 'id'        }, [            {name: 'employee_name', mapping: 'name'},            {name: 'job_title', mapping: 'title'},            {name: 'hire_date', mapping: 'hire_date', type: 'date', dateFormat: 'm-d-Y'},            {name: 'is_active', mapping: 'active'}        ])    });
Toolbar

Add a tab bar to the grid panel. -- almost done.

    var gridFoot = grid.getView().getFooterPanel(true);    var paging = new Ext.PagingToolbar(gridFoot, ds, {        pageSize: 25,        displayInfo: true,        displayMsg: 'Displaying results {0} - {1} of {2}',        emptyMsg: "No results to display"    });

FinallyStartAndLimitParameters to initialize data.

    ds.load({params:{start:0, limit:25}});

A lot of time is spent on how to generate data in the background to work with the grid. Once these jobs are OK, paging the grid is no longer a problem.

Get ['start']. ",".
Gird data

The data on each page of the grid must be divided by the server side.

In this example, the server language is Php and the database is MySQL, which is used to export random data. The following script is used to obtain the data we want and the data is split into pages. The paging parameters are determined by the limit and start variables passed in by the page toolbar.

___FCKpd___0

Because the development environment in each background is different, the server code here is not detailed.

How to Create a grid with pagination

In this exampleScripttagproxyThe reason is that the sample code and the server code are not on the same server (: "cross-origin"), and in most cases, the data is obtained on the same server, you can use httpproxy directly.

The only difference between datastore and datastore is that you need to setTotalproertyAttribute. In this example, we calculate the value of "Total" from the script on the server to tell datastore how many records there are in total. This indicates the number of all records.

___FCKpd___1
Toolbar

Add a tab bar to the grid panel. -- almost done.

___FCKpd___2

FinallyStartAndLimitParameters to initialize data.

___FCKpd___3

A lot of time is spent on how to generate data in the background to work with the grid. Once these jobs are OK, paging the grid is no longer a problem.

Get ['limit'];

$ Rs_count = mysql_query ($ SQL _count );

$ Rows = mysql_num_rows ($ rs_count );

$ Rs = mysql_query ($ SQL );

While ($ OBJ = mysql_fetch_object ($ RS ))
{
$ Arr [] = $ OBJ;
}

Echo
Gird data

The data on each page of the grid must be divided by the server side.

In this example, the server language is Php and the database is MySQL, which is used to export random data. The following script is used to obtain the data we want and the data is split into pages. The paging parameters are determined by the limit and start variables passed in by the page toolbar.

___FCKpd___0

Because the development environment in each background is different, the server code here is not detailed.

How to Create a grid with pagination

In this exampleScripttagproxyThe reason is that the sample code and the server code are not on the same server (: "cross-origin"), and in most cases, the data is obtained on the same server, you can use httpproxy directly.

The only difference between datastore and datastore is that you need to setTotalproertyAttribute. In this example, we calculate the value of "Total" from the script on the server to tell datastore how many records there are in total. This indicates the number of all records.

___FCKpd___1
Toolbar

Add a tab bar to the grid panel. -- almost done.

___FCKpd___2

FinallyStartAndLimitParameters to initialize data.

___FCKpd___3

A lot of time is spent on how to generate data in the background to work with the grid. Once these jobs are OK, paging the grid is no longer a problem.

GET['callback'].'({"total":"'.$rows.'","results":'.json_encode($arr).'})';

Because the development environment in each background is different, the server code here is not detailed.

How to Create a grid with pagination

In this exampleScripttagproxyThe reason is that the sample code and the server code are not on the same server (: "cross-origin"), and in most cases, the data is obtained on the same server, you can use httpproxy directly.

The only difference between datastore and datastore is that you need to setTotalproertyAttribute. In this example, we calculate the value of "Total" from the script on the server to tell datastore how many records there are in total. This indicates the number of all records.

___FCKpd___1
Toolbar

Add a tab bar to the grid panel. -- almost done.

___FCKpd___2

FinallyStartAndLimitParameters to initialize data.

___FCKpd___3

A lot of time is spent on how to generate data in the background to work with the grid. Once these jobs are OK, paging the grid is no longer a problem.

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.