1

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

4

1 回答 1

1

PlatinumGrid 的网站很差,并且没有展示如何实际做事,这很遗憾,因为它是一个非常好的网格,只是缺乏良好的文档。

也就是说,要隐藏您使用 Visible 的列,因此在您的情况下它将是:

$textCol2->Visible=false;

注意我正在使用 $textCol2 ,因为您在示例中使用了两次 $textCol

于 2015-09-29T19:48:02.193 回答