PageRenderTime 59ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/examples/grids/jqRender2.php

http://github.com/wildraid/jqGridPHP
PHP | 77 lines | 57 code | 15 blank | 5 comment | 1 complexity | 655ffbe61d4412372430774f8f04b8a1 MD5 | raw file
  1. <?php
  2. class jqRender2 extends jqGrid
  3. {
  4. protected function init()
  5. {
  6. $this->nav = array(
  7. #Set common nav actions
  8. 'edit' => true,
  9. 'del' => true,
  10. 'view' => true,
  11. #Set text labels. It's better to set them in defaults
  12. 'edittext' => 'Edit',
  13. 'deltext' => 'Delete',
  14. 'viewtext' => 'View',
  15. #Set common excel export
  16. 'excel' => true,
  17. 'exceltext' => 'Excel',
  18. #Set editing params
  19. 'prmEdit' => array('width' => 400,
  20. 'bottominfo' => 'Custom info came from PHP!',
  21. 'viewPagerButtons' => false),
  22. );
  23. $this->table = 'tbl_customer';
  24. $this->cols = array(
  25. 'id' => array('label' => 'ID',
  26. 'width' => 10,
  27. 'align' => 'center',
  28. ),
  29. 'first_name' => array('label' => 'First name',
  30. 'width' => 35,
  31. 'editable' => true,
  32. 'editrules' => array('required' => true),
  33. ),
  34. 'last_name' => array('label' => 'Last name',
  35. 'width' => 35,
  36. 'editable' => true,
  37. 'editrules' => array('required' => true),
  38. ),
  39. 'email' => array('label' => 'Email',
  40. 'width' => 30,
  41. ),
  42. 'phone' => array('label' => 'Phone',
  43. 'width' => 25,
  44. 'align' => 'center',
  45. ),
  46. 'discount' => array('label' => 'Discount',
  47. 'width' => 15,
  48. 'formatter' => 'numeric',
  49. 'align' => 'center',
  50. ),
  51. );
  52. }
  53. protected function renderNav($nav)
  54. {
  55. #Disable 'del' depending on condition
  56. if(mt_rand(1, 10) > 5)
  57. {
  58. $nav['del'] = false;
  59. }
  60. return $nav;
  61. }
  62. }