cancel
Showing results for 
Search instead for 
Did you mean: 

Display the Columns in the grid at run time

Former Member
0 Kudos

Hi,

My Query is returning fix number of columns in the output.I dont want to Explicitly set the columns i want to see in the display template(display columns field) rather i want to show the number of columns in the grid at run time selected by the user.

Any Suggestion.

Thankyou in Advance.

Nikhil

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

A simple glance through the xMII Help Documentationg would yield the following:

You can get a list of the columns for display to the users via the following: document.iGrid.getQueryObject().getColumns()

You can then run your query with user selected columns with the following: document.iGrid.getGridObject().setDisplayColumns(NEWVALUE);

where NEWVALUE would be a string list of your columns you desire.

Hope this helps...

Former Member
0 Kudos

Hi Alin,

Thanks for the suggestion and Sorry for the delay in reply.

Problem is that below Function does not give me any result.when i m using alert to see the result it is showing square shape boxes.

document.iGrid.getQueryObject().getColumns()

also document.iGrid.getGridObject().setDisplayColumns(NEWVALUE); not setting the columns i want to display.i am writing the code as :

document.Appletname.getGridObject().setDisplayColumns("column1,column2");

Thanks.

Nikhil

Former Member
0 Kudos

Hi Nikhil,

As far as setting the columns to a new value, are you using the document.iGrid.updateGrid(true) function to update the grid to show the new columns (I assume iGrid is the name of your applet)?

If you do

alert(document.iGrid.getQueryObject().getColumns());

you are getting no result?

Kind Regards,

Diana Hoppe

Former Member
0 Kudos

Here's is what i came up with:

YOu can run one query to get the list of all columns from a table using the following SQL code:

SELECT COLUMN_NAME 

FROM INFORMATION_SCHEMA.COLUMNS 

WHERE TABLE_NAME = 'Customers'

Once you do that you can run the query for your table with the selected columns with the following applet property code:

function MyFunc(){
			document.MyApplet.getGridObject().setDisplayColumns('CompanyName,City');
			document.MyApplet.updateGrid(true);
	}

User the following to extract all selected rows:

selRows = parseInt(myGrid.getSelectedRowCount());

You then itterate through the iGrid to extract the value:

for (var i=1; i<=selRows; i++) {

selRowNum = myGrid.getSelectedRowAt(i);

selDate = myGrid.getCellValue(selRowNum,1);

}

jcgood25
Active Contributor
0 Kudos

All SQLQuery templates support the ColumnList query Mode too, which is not DB specific like your select statement: http://localhost/Lighthammer/Illuminator?Server=Northwind&Mode=ColumnList&Group=Employees

Answers (0)