Advertisement
Guest User

Remove + expand for condition

a guest
Sep 16th, 2014
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.06 KB | None | 0 0
  1. <?php
  2. /**
  3.  * PHP Grid Component
  4.  *
  5.  * @author Abu Ghufran <gridphp@gmail.com> - http://www.phpgrid.org
  6.  * @version 1.5.2
  7.  * @license: see license.txt included in package
  8.  */
  9.  
  10. // include db config
  11. include_once("../../config.php");
  12.  
  13. // set up DB
  14. mysql_connect(PHPGRID_DBHOST, PHPGRID_DBUSER, PHPGRID_DBPASS);
  15. mysql_select_db(PHPGRID_DBNAME);
  16.  
  17. // include and create object
  18. include(PHPGRID_LIBPATH."inc/jqgrid_dist.php");
  19.  
  20. $grid = new jqgrid();
  21.  
  22. $opt["caption"] = "Clients Data";
  23. $opt["height"] = "";
  24. $opt["rowNum"] = "5";
  25.  
  26. // following params will enable subgrid -- by default 'rowid' (PK) of parent is passed
  27. $opt["subGrid"] = true;
  28. $opt["subgridurl"] = "subgrid_detail.php";
  29. $opt["loadComplete"] = "function(){ do_onload(); }";
  30.  
  31. //call some JS on subgrid load
  32. //$opt["subGridRowExpanded"] = "function(){ setTimeout(function(){ alert('connect ckeditor code'); },200);  }";
  33.  
  34. $opt["subgridparams"] = "client_id";
  35. // $opt["subgridparams"] = "name,gender,company"; // comma sep. fields. will be POSTED from parent grid to subgrid, can be fetching using $_POST in subgrid
  36. $grid->set_options($opt);
  37.  
  38. $grid->table = "clients";
  39. $out = $grid->render("list1");
  40. ?>
  41. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  42. <html>
  43. <head>
  44.     <link rel="stylesheet" type="text/css" media="screen" href="../../lib/js/themes/start/jquery-ui.custom.css"></link>
  45.     <link rel="stylesheet" type="text/css" media="screen" href="../../lib/js/jqgrid/css/ui.jqgrid.css"></link> 
  46.    
  47.     <script src="../../lib/js/jquery.min.js" type="text/javascript"></script>
  48.     <script src="../../lib/js/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>
  49.     <script src="../../lib/js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script> 
  50.     <script src="../../lib/js/themes/jquery-ui.custom.min.js" type="text/javascript"></script>
  51. </head>
  52. <body>
  53.     <div style="margin:10px">
  54.     Subgrid example ... this file will load subgrid defined in 'subgrid_detail.php'
  55.     <br>
  56.     <br>
  57.     <?php echo $out?>
  58.     </div>
  59.     <script type="text/javascript">
  60.     jQuery(document).ready(function(){
  61.  
  62.         jQuery('#list1').jqGrid('navButtonAdd', '#list1_pager',
  63.         {
  64.             'caption'      : 'Toggle Expand',
  65.             'buttonicon'   : 'ui-icon-plus',
  66.             'onClickButton': function()
  67.             {
  68.                
  69.                 var rowIds = jQuery("#list1").getDataIDs();
  70.                
  71.                 if ( ! jQuery(document).data('expandall') )
  72.                 {
  73.                     jQuery.each(rowIds, function (index, rowId) { jQuery("#list1").expandSubGridRow(rowId); });
  74.                     jQuery(document).data('expandall',1);
  75.                 }
  76.                 else
  77.                 {
  78.                     jQuery.each(rowIds, function (index, rowId) { jQuery("#list1").collapseSubGridRow(rowId); });
  79.                     jQuery(document).data('expandall',0);
  80.                 }
  81.                
  82.             },
  83.             'position': 'last'
  84.         });
  85.     });
  86.    
  87.     function do_onload()
  88.     {
  89.         var grid = $("#list1");
  90.         var ids = grid.jqGrid('getDataIDs');
  91.         for (var i=0;i<ids.length;i++)
  92.         {
  93.             var id=ids[i];
  94.             if (grid.jqGrid('getCell',id,'gender') == 'male')
  95.             {
  96.                 jQuery('tr#'+i+' td.ui-sgcollapsed').replaceWith('<td>');
  97.             }
  98.         }
  99.     }  
  100.     </script>  
  101. </body>
  102. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement