CREATE TABLE `articles` ( `id` int ( 11 ) NOT NULL AUTO_INCREMENT , `title` varchar ( 255 ) , `shorttext` text , `createdate` datetime , `text` text , PRIMARY KEY ( `id` ) ) ;
CREATE TABLE `articles` ( `id` int ( 11 ) NOT NULL AUTO_INCREMENT , `title` varchar ( 255 ) , `shorttext` text , `createdate` datetime , `text` text , PRIMARY KEY ( `id` ) ) ;
CREATE TABLE `articles` ( `id` int ( 11 ) NOT NULL AUTO_INCREMENT , `title` varchar ( 255 ) , `shorttext` text , `createdate` datetime , `text` text , PRIMARY KEY ( `id` ) ) ;
CREATE TABLE `articles` ( `id` int ( 11 ) NOT NULL AUTO_INCREMENT , `title` varchar ( 255 ) , `shorttext` text , `createdate` datetime , `text` text , PRIMARY KEY ( `id` ) ) ;
CREATE TABLE `articles` ( `id` int ( 11 ) NOT NULL AUTO_INCREMENT , `title` varchar ( 255 ) , `shorttext` text , `createdate` datetime , `text` text , PRIMARY KEY ( `id` ) ) ;
CREATE TABLE `articles` ( `id` int ( 11 ) NOT NULL AUTO_INCREMENT , `title` varchar ( 255 ) , `shorttext` text , `createdate` datetime , `text` text , PRIMARY KEY ( `id` ) ) ;
CREATE TABLE `articles` ( `id` int ( 11 ) NOT NULL AUTO_INCREMENT , `title` varchar ( 255 ) , `shorttext` text , `createdate` datetime , `text` text , PRIMARY KEY ( `id` ) ) ;
CREATE TABLE `articles` ( `id` int ( 11 ) NOT NULL AUTO_INCREMENT , `title` varchar ( 255 ) , `shorttext` text , `createdate` datetime , `text` text , PRIMARY KEY ( `id` ) ) ;
- var record = Ext. data . Record . create ( [
- { name : 'id' , type : 'int' } ,
- { name : 'title' } ,
- { name : 'createdate' , type : 'date' , dateFormat : 'Ymd h: i: s' } ,
- ] ) ;
- var ds = new Ext. data . Store ( {
- remoteSort : false ,
- proxy : new Ext. data . HttpProxy ( {
- url : '/ grid / grid /'
- } )
- reader : new Ext. data . JsonReader ( {
- root : 'result' ,
- totalProperty : 'totalCount'
- } , record )
- } ) ;
- paddingBar = new Ext. PagingToolbar ( {
- pageSize : 10 ,
- store : ds ,
- displayInfo : true
- displayMsg : 'Displaying topics {0} - {1} of {2}' ,
- emptyMsg : "No topics to display"
- } ) ;
- var renderDate = function ( value , p , record ) {
- return value. format ( "j / n / YH: i: s" ) ;
- } ;
- var grid = new Ext. grid . GridPanel ( {
- store : ds ,
- trackMouseOver : false ,
- loadMask : true
- columns : [ {
- id : 'id' ,
- header : "Id" ,
- dataIndex : 'id' ,
- width : 40 ,
- sortable : true
- } , {
- header : "Title" ,
- dataIndex : 'title' ,
- width : 300 ,
- sortable : true
- } , {
- header : "Createdate" ,
- dataIndex : 'createdate' ,
- width : 200 ,
- renderer : renderDate ,
- sortable : true
- } ] ,
- tbar : [
- new Ext. Button ( {
- text : 'New' ,
- handler : addRecord
- } )
- new Ext. Button ( {
- text : 'Edit' ,
- handler : editRecord
- } )
- new Ext. Button ( {
- text : 'Delete' ,
- handler : deleteRecords
- } )
- ] ,
- bbar : paddingBar
- } ) ;
- grid. on ( "rowdblclick" , editRecord ) ;
- var window = new Ext. Window ( {
- id : 'example-window' ,
- title : "Grid Example" ,
- layout : 'fit' ,
- width : 800 ,
- height : 400 ,
- items : [ grid ]
- } ) ;
- window. show ( ) ;
- grid. getStore ( ) . load ( ) ;
- class GridController extends Zend_Controller_Action
- {
- ...
- }
- class Grid extends Zend_Db_Table_Abstract
- {
- public function getCountRows ( )
- {
- $ select = $ this -> select ( ) -> from ( array ( 'p' => $ this -> _name ) , array ( 'c' => 'COUNT (*)' ) ) ;
- $ stmt = $ select -> query ( ) ;
- $ result = $ stmt -> fetchAll ( ) ;
- return $ result [ 0 ] [ 0 ] ;
- }
- }
- public function gridAction ( )
- {
- $ this -> _helper -> viewRenderer -> setNoRender ( ) ;
- require_once 'Grid.php' ;
- $ grid = new Grid ( array ( 'name' => 'articles' ) ) ;
- $ totalCount = $ grid -> getCountRows ( ) ;
- $ where = null ;
- $ order = "id" ;
- $ limit = $ this -> getRequest ( ) -> getParam ( 'limit' , 5 ) ;
- $ start = $ this -> getRequest ( ) -> getParam ( 'start' , 0 ) ;
- $ rows = $ grid -> fetchAll ( $ where , $ order , $ limit , $ start ) ;
- $ data = array (
- 'totalCount' => $ totalCount ,
- 'result' => $ rows -> toArray ( )
- ) ;
- echo json_encode ( $ data ) ;
- }
Source: https://habr.com/ru/post/79679/
All Articles