Framework PHP-EXT similar to GWT in PHP

Source: Internet
Author: User

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?
  1. <? PHP
  2. /*
  3. * @ Author Matthias benkwitz
  4. * @ Website <a href = "http://www.bui-hinsche.de" target = _ blank> http://www.bui-hinsche.de </a>
     
  5. */
  6. Set_include_path (get_include_path (). path_separator.realpath ('.../../library '));
  7. Include_once 'phpext/JavaScript. php ';
  8. Phpext_javascript: sendcontenttype ();
  9. $ Httphost = "http: //". $ _ server ['HTTP _ host'];
  10. $ Docroot = str_replace ("//", "/", realpath ($ _ server ['document _ root']);
  11. $ Dir = str_replace ("//", "/", realpath (dirname (_ file __)."/.."));
  12. $ Baseurl = str_replace ($ docroot, $ httphost, $ DIR );
  13. Include_once 'phpext/EXT. php ';
  14. Include_once 'phpext/data/simplestore. php ';
  15. Include_once 'phpext/data/arrayreader. php ';
  16. Include_once 'phpext/data/jsonreader. php ';
  17. Include_once 'phpext/data/scripttagproxy. php ';
  18. Include_once 'phpext/data/fieldconfigobject. php ';
  19. Include_once 'phpext/data/storeloadoptions. php ';
  20. Include_once 'phpext/data/httpproxy. php ';
  21. Include_once 'phpext/data/jsonstore. php ';
  22. Include_once 'phpext/toolbar/pagingtoolbar. php ';
  23. Include_once 'phpext/GRID/columnmodel. php ';
  24. Include_once 'phpext/GRID/columnconfigobject. php ';
  25. Include_once 'phpext/GRID/gridpanel. php ';
  26. $ Pagesize = 10;
  27. $ Changerenderer = phpext_javascript: functiondef ("change", "If (Val> 0 ){
  28. Return '<span style =/"color: green;/">' + Val + '</span> ';
  29. } Else if (Val <0 ){
  30. Return '<span style =/"color: red;/">' + Val + '</span> ';
  31. }
  32. Return val; ", array (" Val "));
  33. $ Pctchangerenderer = phpext_javascript: functiondef ("pctchange", "If (Val> 0 ){
  34. Return '<span style =/"color: green;/">' + Val + '% </span> ';
  35. } Else if (Val <0 ){
  36. Return '<span style =/"color: red;/">' + Val + '% </span> ';
  37. }
  38. Return val; ", array (" Val "));
  39. $ Reader = new phpext_data_jsonreader ();
  40. $ Reader-> setroot ("topics ")
  41. -> Settotalproperty ("totalcount ")
  42. -> Setid ("ID ");
  43. $ Reader-> addfield (New phpext_data_fieldconfigobject ("company "));
  44. $ Reader-> addfield (New phpext_data_fieldconfigobject ("price", null, "float "));
  45. $ Reader-> addfield (New phpext_data_fieldconfigobject ("change", null, "float "));
  46. $ Reader-> addfield (New phpext_data_fieldconfigobject ("pctchange", null, "float "));
  47. $ Reader-> addfield (New phpext_data_fieldconfigobject ("lastchange", null, "date", "N/j h: IA "));
  48. $ Reader-> addfield (New phpext_data_fieldconfigobject ("industry "));
  49. // Store
  50. $ Store = new phpext_data_store ();
  51. $ Store-> seturl ($ baseurl. '/GRID/json_exampledata.php ')
  52. -> Setreader ($ reader)
  53. -> Setbaseparams (Array ("Limit" => $ pagesize ));
  54. // Columnmodel
  55. $ Colmodel = new phpext_grid_columnmodel ();
  56. $ Colmodel-> AddColumn (phpext_grid_columnconfigobject: createcolumn ("company", 160, null, null, true, false ))
  57. -> AddColumn (phpext_grid_columnconfigobject: createcolumn ("price", "price", null, 75, null, phpext_javascript: variable ("Ext. util. format. usmoney "), true, true ))
  58. -> AddColumn (phpext_grid_columnconfigobject: createcolumn ("change", "change", null, 75, null, phpext_javascript: variable ('change'), null, true ))
  59. -> AddColumn (phpext_grid_columnconfigobject: createcolumn ("% change", "pctchange", null, 75, null, phpext_javascript: variable ('pctchang'), null, true ))
  60. -> AddColumn (phpext_grid_columnconfigobject: createcolumn ("Last updated", "lastchange", null, 85, null, phpext_javascript: variable ("Ext. util. format. daterenderer ('m/D/Y') "), null, true ))
  61. -> AddColumn (phpext_grid_columnconfigobject: createcolumn ("industry", "industry", null, 85, null, null, true, true ));
  62. // Grid
  63. $ Grid = new phpext_grid_gridpanel ();
  64. $ Grid-> setstore ($ store)
  65. -> Setcolumnmodel ($ colmodel)
  66. -> Setstriperows (true)
  67. -> Setautoexpandcolumn ("company ")
  68. -> Setheight (350)
  69. -> Setwidth (600)
  70. -> Settitle ("JSON grid ");
  71. $ Paging = new phpext_toolbar_pagingtoolbar ();
  72. $ Paging-> setstore ($ store)
  73. -> Setpagesize ($ pagesize)
  74. -> Setdisplayinfo ("topics {0}-{1} of {2 }")
  75. -> Setemptymessage ("no topics to display ");
  76. $ Grid-> setbottomtoolbar ($ paging );
  77. // Ext. onready -----------------------
  78. Echo phpext_ext: onready (
  79. $ Changerenderer,
  80. $ Pctchangerenderer,
  81. $ Store-> getjavascript (false, "Store "),
  82. $ Store-> load (New phpext_data_storeloadoptions (Array (
  83. "Start" => 0, "Limit" => $ pagesize ))
  84. ),
  85. $ Grid-> getjavascript (false, "Grid "),
  86. $ Grid-> render ("Grid-Example ")
  87. );
  88. ?>

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.