简体   繁体   中英

How to hide columns in platinumgrid php

I am using Platinumgrid in my code and I want to hide last name column in the grid.

I also checked this url http://www.platinumgrid.com/hiddencolumns.php but cannot find any solution for my task.

Here is my code:

<?php 
require_once( 'grid.inc.php' ); 

$dbConnection = mysql_connect( 'localhost', 'root', '' ); 

mysql_select_db( 'gridsamples', $dbConnection ); 

$dataSource = new MySQLDatasource( $dbConnection ); 
$dataSource->DataSet->TableName = 'employeestiny'; 

// Construct the grid. 
$grid = new JTPlatinumGrid(); 
$grid->Datasource = $dataSource; 
$grid->Header->SimpleFilter = false; 
$grid->Height = ''; 
$grid->SiteTheme->Theme = 'default'; 

$textCol = new JTPlatinumGridTextColumn( $grid ); 
$textCol->Caption = 'First Name'; 
$textCol->DataField = 'FirstName'; 
$textCol->Name = 'FirstNameCol'; 

$textCol = new JTPlatinumGridTextColumn( $grid ); 
$textCol->Caption = 'Last Name'; 
$textCol->DataField = 'LastName'; 
$textCol->Name = 'LastNameCol'; 

$dateCol = new JTPlatinumGridDateTimeColumn( $grid ); 
$dateCol->Caption = 'Date'; 
$dateCol->DataField = 'DateCol'; 
$dateCol->Display = JTPlatinumGridDateTimeColumn::DateOnly; 
$dateCol->Name = 'DateCol'; 

$grid->Columns = array( $textCol, $dateCol ); 

$grid->init(); 
?> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<html> 
<head> 
  <title>Basic Columns Demo</title> 
<?php 
$grid->dumpHeaderCode(); 
?> 
</head> 
<body> 
  <h1>Basic Columns Demo</h1> 
  <form action="" method="post"> 
    <div id="<?php echo( $grid->Name ); ?>_outer"> 
<?php $grid->dumpContents(); ?> 
    </div> 
  </form> 
</body> 
</html>

First time I am using Platinumgrid. Hoping for positive response. Thanks

The website for PlatinumGrid is pretty poor and doesn't show how to actually do things which is a shame as it is a pretty good grid just lacking good documentation.

That said, to hide a column you use Visible so in your case it would be:

$textCol2->Visible=false;

Note I am using $textCol2 as you are using $textCol twice in your example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM