|
|
 Joe Buchman - 2009-08-30 05:32:48
Hello,
I have read the documentation but cannot identfy how to stop a column from displaying in the drastic grid.
Is there a setting? From a table how do I selectively show only some columns?
Any assistance is appreciated.
Joe
 dd - 2009-08-30 09:22:05 - In reply to message 1 from Joe Buchman
Hi Joe,
You can specify the columns to be shown in the grid using the
'columns' parameter in the Javscript call, like this:
Example 1:
var thegrid = new drasticGrid('grid1', {
pathimg:"img/",
pagelength: 10,
columns: [
{name: 'id', width: 40},
{name: 'name', displayname: 'First Name'},
{name: 'email', type: DDTYPEMAILTO, width: 140, editable: false},
{name: 'www', type: DDTYPEURL, width: 180, editable: true},
{name: 'present', editable: false}
],
sliderposition: "left",
onClick: function(id){thegrid.DefaultOnClick(id); alert('clicked on row with id = '+id)}
});
here, only the fields 'id', 'name', 'email', 'www' and 'present' will be shown. Leave out the fields you don't want.
regards, DrasticData
 Joe Buchman - 2009-08-30 09:47:20 - In reply to message 2 from dd
Of course!..many thanks for the solution.
 David M - 2010-06-17 20:55:56 - In reply to message 2 from dd
I know this is a probably-dead thread, but here's another trick.
Alter the xxxxx.class.php (whatever class file you're using) file to accept a new 'field' in the $options parameter. If you search through the original xxxx.class.php, and look for the comment below (// Get the table in memory) and add the ternary-operator line below (the last line - after ADDED...). Thus, if you don't set $options['cols2show'], nothing different happens.
// Get the table in memory
$this->result = $this->select($userID);
$this->num_rows = mysql_num_rows($this->result);
$this->num_fields = mysql_num_fields($this->result);
// ADDED allows one to ‘set’ which columns even show up in the datagrid
$this->cols = ($options['cols2show']) ? $options['cols2show'] : $this->cols;
Then you can add another key+array to $options that has an array of the columns you'd like to see. For example:
$options['cols2show']=array('UserID', 'AnotherColumn', 'YetAnotherColumn', 'MoreColumnsAsNeeded');
Setting $options is done in the .php file that calls/instantiates the xxxxx.class.php file.
Hope that helps,
David
|