PDA

View Full Version : How to add Variable in Title:???



mmaxtra001
22 Feb 2010, 7:50 AM
Hi:
I am totally a newbie to this but I wanted to know how to add a variable attribute to the title section for example I would like the header/title to say .. I am using Data Grid...
Detail Report for: [then the variable name]
Here is my code:
// CREATE THE GRID
var grid = new Ext.grid.GridPanel({store: store, columns: [
{id: 'Student', header: "Student", width: 50, sortable: true, dataIndex: 'Student'}
],
stripeRows:true,
autoExpandColumn: 'Student',
height: 500, width: 1000,
stateful: true,
stateId: 'grid',
title: 'Detail Report For:'});

Thanks

Animal
22 Feb 2010, 8:06 AM
String concatenation?

mmaxtra001
22 Feb 2010, 8:30 AM
I did try that but did not work...
Maybe I have the wrong syntax:
// CREATE THE GRID
var grid = new Ext.grid.GridPanel({store: store, columns: [
{id: 'Student', header: "Student", width: 50, sortable: true, dataIndex: 'Student'}
],
stripeRows:true,
autoExpandColumn: 'Student',
height: 500, width: 1000,
stateful: true,
stateId: 'grid',
title: 'Detail Report For:' + Student}); <== I believe this is wrong...

sunco
22 Feb 2010, 8:50 AM
If you want it directly with Php you need this way:


title: 'Detail Report For: <? echo $your_var; ?>'});

If the grid is filled with an event then:


grid.setTitle('Your new title here');

mmaxtra001
22 Feb 2010, 9:17 AM
I am basically doing this in salesforce.com environment. I have the grid up but instead of showing the same student name over and over again I figure I place the student name up in the title section.
stripeRows:true,
autoExpandColumn: 'Student', <== here is the Student Name
height: 500, width: 1000,
stateful: true,
stateId: 'grid',
title: 'Detail Report For: ' + store});

This gave me Detail Report For: [object Object]

which I have no idea what that refers to...
As for the grid I call it through div tags
<div id="displayhere"></div>

evanc
22 Feb 2010, 9:55 AM
title: 'Detail Report For: ' + store});

"store" is (presumably) an Ext.data.Store object, not a string. You need to determine how to get the student's name as a string (you might have to read the documentation for Store (http://www.extjs.com/deploy/dev/docs/?class=Ext.data.Store)) and concatenate that to the title of the grid.