Http://php-ext.quimera-solutions.com/
Currently, there are not a few people engaged in PHP website development, and there are even fewer people using extjs. However, many PHP programmers are not familiar with JavaScript, but they like extjs very much. in the past, they could only look at Java or. NET developers can use the server language to write extjs, PHP also has a similar box PHP-EXT.
The following is an example of a simple DataGrid:
To achieve the above effect, you do not need to write a JS Code.
View plaincopy to clipboardprint?
- <? PHP
- /*
- * @ Author Matthias benkwitz
- * @ Website <a href = "http://www.bui-hinsche.de" target = _ blank> http://www.bui-hinsche.de </a>
- */
- Set_include_path (get_include_path (). path_separator.realpath ('.../../library '));
- Include_once 'phpext/JavaScript. php ';
- Phpext_javascript: sendcontenttype ();
- $ Httphost = "http: //". $ _ server ['HTTP _ host'];
- $ Docroot = str_replace ("//", "/", realpath ($ _ server ['document _ root']);
- $ Dir = str_replace ("//", "/", realpath (dirname (_ file __)."/.."));
- $ Baseurl = str_replace ($ docroot, $ httphost, $ DIR );
- Include_once 'phpext/EXT. php ';
- Include_once 'phpext/data/simplestore. php ';
- Include_once 'phpext/data/arrayreader. php ';
- Include_once 'phpext/data/jsonreader. php ';
- Include_once 'phpext/data/scripttagproxy. php ';
- Include_once 'phpext/data/fieldconfigobject. php ';
- Include_once 'phpext/data/storeloadoptions. php ';
- Include_once 'phpext/data/httpproxy. php ';
- Include_once 'phpext/data/jsonstore. php ';
- Include_once 'phpext/toolbar/pagingtoolbar. php ';
- Include_once 'phpext/GRID/columnmodel. php ';
- Include_once 'phpext/GRID/columnconfigobject. php ';
- Include_once 'phpext/GRID/gridpanel. php ';
- $ Pagesize = 10;
- $ Changerenderer = phpext_javascript: functiondef ("change", "If (Val> 0 ){
- Return '<span style =/"color: green;/">' + Val + '</span> ';
- } Else if (Val <0 ){
- Return '<span style =/"color: red;/">' + Val + '</span> ';
- }
- Return val; ", array (" Val "));
- $ Pctchangerenderer = phpext_javascript: functiondef ("pctchange", "If (Val> 0 ){
- Return '<span style =/"color: green;/">' + Val + '% </span> ';
- } Else if (Val <0 ){
- Return '<span style =/"color: red;/">' + Val + '% </span> ';
- }
- Return val; ", array (" Val "));
- $ Reader = new phpext_data_jsonreader ();
- $ Reader-> setroot ("topics ")
- -> Settotalproperty ("totalcount ")
- -> Setid ("ID ");
- $ Reader-> addfield (New phpext_data_fieldconfigobject ("company "));
- $ Reader-> addfield (New phpext_data_fieldconfigobject ("price", null, "float "));
- $ Reader-> addfield (New phpext_data_fieldconfigobject ("change", null, "float "));
- $ Reader-> addfield (New phpext_data_fieldconfigobject ("pctchange", null, "float "));
- $ Reader-> addfield (New phpext_data_fieldconfigobject ("lastchange", null, "date", "N/j h: IA "));
- $ Reader-> addfield (New phpext_data_fieldconfigobject ("industry "));
- // Store
- $ Store = new phpext_data_store ();
- $ Store-> seturl ($ baseurl. '/GRID/json_exampledata.php ')
- -> Setreader ($ reader)
- -> Setbaseparams (Array ("Limit" => $ pagesize ));
- // Columnmodel
- $ Colmodel = new phpext_grid_columnmodel ();
- $ Colmodel-> AddColumn (phpext_grid_columnconfigobject: createcolumn ("company", 160, null, null, true, false ))
- -> AddColumn (phpext_grid_columnconfigobject: createcolumn ("price", "price", null, 75, null, phpext_javascript: variable ("Ext. util. format. usmoney "), true, true ))
- -> AddColumn (phpext_grid_columnconfigobject: createcolumn ("change", "change", null, 75, null, phpext_javascript: variable ('change'), null, true ))
- -> AddColumn (phpext_grid_columnconfigobject: createcolumn ("% change", "pctchange", null, 75, null, phpext_javascript: variable ('pctchang'), null, true ))
- -> AddColumn (phpext_grid_columnconfigobject: createcolumn ("Last updated", "lastchange", null, 85, null, phpext_javascript: variable ("Ext. util. format. daterenderer ('m/D/Y') "), null, true ))
- -> AddColumn (phpext_grid_columnconfigobject: createcolumn ("industry", "industry", null, 85, null, null, true, true ));
- // Grid
- $ Grid = new phpext_grid_gridpanel ();
- $ Grid-> setstore ($ store)
- -> Setcolumnmodel ($ colmodel)
- -> Setstriperows (true)
- -> Setautoexpandcolumn ("company ")
- -> Setheight (350)
- -> Setwidth (600)
- -> Settitle ("JSON grid ");
- $ Paging = new phpext_toolbar_pagingtoolbar ();
- $ Paging-> setstore ($ store)
- -> Setpagesize ($ pagesize)
- -> Setdisplayinfo ("topics {0}-{1} of {2 }")
- -> Setemptymessage ("no topics to display ");
- $ Grid-> setbottomtoolbar ($ paging );
- // Ext. onready -----------------------
- Echo phpext_ext: onready (
- $ Changerenderer,
- $ Pctchangerenderer,
- $ Store-> getjavascript (false, "Store "),
- $ Store-> load (New phpext_data_storeloadoptions (Array (
- "Start" => 0, "Limit" => $ pagesize ))
- ),
- $ Grid-> getjavascript (false, "Grid "),
- $ Grid-> render ("Grid-Example ")
- );
- ?>