cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Setting column headings in Javascript on xMII 11.5 iGrid

Former Member
0 Likes
212

I am using 11.5 xMII, I have varying columns returned from a dynamic query in a iGrid, I am trying to set the headers in the Javascript. I tried both setColumnHeader and setColumnHeaders and it does not work. See my code below ...

var DataQryObj = document.getElementById('xxx').getQueryObject();

var DataDispObj = document.getElementById('xxx').getGridObject();

var colHeaders = '', colWidths = '';

DataQryObj.setParam(1,'a');

colHeaders = 'Year,Time Period,,';

colWidths = '10,10,0,0';

DataDispObj.setColumnHeadings(colHeaders); //THIS WORKS

DataDispObj.setColumnWidths(colWidths); //THIS WORKS

for(var i=5;i<DataDispObj.getColumnCount();i++) {

DataDispObj.setColumnWidth(i,0); //DOESNT WORK

DataDispObj.setColumnHeading(i,'XXXXX'); //DOESNT WORK

colHeaders = (',,''ZZZZZ');

colWidths += (',0,10');

}

DataDispObj.setColumnHeadings(colHeaders); //DOESNT WORK

DataDispObj.setColumnWidths(colWidths); //DOESNTWORK

Any help is appreciated.

thanks

Sreenivasa

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

And don't forget to updateGrid; see below:

var Customers = document.Customers;
var CustomersGrid = Customers.getGridObject();
var columnCount = CustomersGrid.getColumnCount();

CustomersGrid.setColumnHeadings("1,2,3,4,5,6");
Customers.updateGrid(true);
				
for (var i=0; i<columnCount; i++) {
	alert(CustomersGrid.getColumnHeading(i));
}

Answers (1)

Answers (1)

Former Member
0 Likes

sreenivasa,

How many columns are there in your grid? In your for loop, you are starting the loop count "i" at 5. So if you only have 4 columns (DataDispObj.getColumnCount()), your loop won't run at all.