Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
How to get a column index/name
aesfandi
I need to pickup a column name of a cell in onCreate. It seems possible to
use getColumnName(index) but I have a hard time finding the "index" for the
current column. There is a getColumnCount() function that returns the total
number of column bindings but how can I get the index of the current column?
What I want to do is to to use the same script in onCreate for each column of
a table and pickup the column name on the fly.
Example:
I have a table with Date, ColA, ColB, ColC, etc.. columns.I want to use the same script
in each of ColA, ColB, ColC, ... onCreate to pickup the column names:
if( this.getValue() == -1){
var mydate = row["Date"];
oRow = this.getRowData();
iRowNumber = row.__rownum; // this gives me row number but how do I get the column number?
iColCount= oRow.getColumnCount();
iColIndex = ? **** Need to get the index of this (current) column to pass to getColumnName ****
this.helpText = mydate+", Error in "+oRow.getColumnName(iColIndex);
}
Thanks.
Find more posts tagged with
Comments
mwilliams
Where are you placing this script? If scripting on a cell, you can use this.getColumn(), which returns an integer. If you're placing the code individually in each column, couldn't you put a static integer in each column's script?
aesfandi
I'm placing the script in each individual column. How can I use a cell script? I would prefer to do it that way if possible.
I'm using table palettes with data read from flat .csv files. Depending on various .csv files and dataset, each table contains different number of columns. The first column, Date, is common among all tables. It will be easier and more efficient if the cell script method you refer to could work for me. I prefer to use the same script to work for all tables (pickup the column index and column name automatically). Any hint is much appreciated. Thank you.
mwilliams
So, you're currently scripting on the data element in the cell, not the column, right? I'm pretty sure there are no scripting methods on the columns. Let me know. What you're trying to do is show a help text if there is a bad value that shows you the column name that has the error? Is that what I'm seeing your script is doing?