Controlling table column alignment using variable
Hi I'm new to Javascript, having only used Applescript before.
I'm using Indesign 5.5 on Mac and I'm learning Javascript by adapting old Applescripts that I have been using for years.
So, with an existing table, one of the things I want to do is to set the alignments in the columns using a varible. Here's what I've tried so far:
function setColumnWidthsAndAlignments()
var myWidths=[29, 23, 13, 13, 13, 13];
var myAlignments=["leftAlign","leftAlign","centerAlign","centerAlign","rightAlign","rightAlign"];
var numberOfColumns=myTable.columns.count();
for (c=0;c<numberOfColumns;c++)
myTable.columns[c].width=myWidths[c];
myTable.columns[c].cells.everyItem().texts.everyItem().justification=Justification.myAlignments[c];
but I get an error
-- Object does not support the property or method 'myAlignments' --
If I discard the variable myAlignments and just put leftAlign for example, it works, so maybe I'm not declaring the variable properly?
I know I could add a few extra paragraph styles and cell styles and style the table that way, but I though this would be a good learning exercise (besides which I want to limit the number of paragraph styles in the document - there are enough already!)
If anybody is really interested, I'd like to place the whole script here and would really welcome any feedback on how the structure could be improved or optimised or just tell me if I'm heading in the right direction.
Thanks and regards,
Malcolm
//Simple table script 1
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll; //make sure that user interactivity is switched on ???? why????
if(checkForOpenDocs()) //checks to see if there are any open Indesign documents
if(targetMyTable()) //checks to see if the selection is inside a table - if not, gives an error dialog - if it is, returns variable myTable which can be used to target different parts of the table
// selectLastRow();
//resetTable();
//applyTableTextParaStyle();
//removeRules();
//applyAlternatingFills();
setColumnWidthsAndAlignments();
//setRowHeightsAndInsets();
function checkForOpenDocs()
if (app.documents.length!=0) //there is at least one document open
myDocument = app.documents.item(0); //get the id of the frontmost document - might be useful?
return true;
else
alert("There are no documents open");
return false;
function targetMyTable() //no matter what is selected in the table, change selection to be whole table
if(app.selection[0]==null) //if there is nothing selected
alert("There is nothing selected.");
return false
var mySelection = app.selection[0];
switch(mySelection.constructor.name)
//When a row, a column, or a range of cells is
//selected, the type returned is always "Cell"
case "Cell":
myTable=mySelection.parent;
return true
break;
case "Table":
myTable=mySelection;
return true
break;
case "InsertionPoint":
case "Character":
case "Word":
case "TextStyleRange":
case "Line":
case "Paragraph":
case "TextColumn":
case "Text":
if(app.selection[0].parent.constructor.name == "Cell")
myTable=mySelection.parent.parent;
return true
else
alert("The selection is not inside a table.");
return false
break;
case "Rectangle":
case "Oval":
case "Polygon":
case "GraphicLine":
case "TextFrame":
if(app.selection[0].parent.parent.constructor.name == "Cell")
myTable=mySelection.parent.parent.parent;
return true
else
alert("The selection is not inside a table.");
return false
break;
case "Image":
case "PDF":
case "EPS":
if(app.selection[0].parent.parent.parent.constructor.name == "Cell")
myTable=mySelection.parent.parent.parent.parent;
return true
else
alert("The selection is not inside a table.");
return false
break;
default:
break;
function resetTable()
myTable.cells.everyItem().clearCellStyleOverrides (true);
function selectLastRow()
//myTable.cells.itemByRange(0,-1).select();
myTable.rows.itemByRange(-1,-1).select();
function applyTableTextParaStyle()
myParagraphStyle=myDocument.paragraphStyles.item("•table text");
myTable.cells.everyItem().texts.everyItem().appliedParagraphStyle = myParagraphStyle;
function removeRules()
myTable.cells.everyItem().topEdgeStrokeWeight=0;
myTable.cells.everyItem().bottomEdgeStrokeWeight=0;
myTable.cells.everyItem().leftEdgeStrokeWeight=0;
myTable.cells.everyItem().rightEdgeStrokeWeight=0;
function applyAlternatingFills()
myColor=myDocument.swatches.item("Black");
myTable.alternatingFills=AlternatingFillsTypes.alternatingRows;
myTable.startRowFillColor=myColor;
myTable.startRowFillTint=20;
myTable.endRowFillColor=myColor;
myTable.endRowFillTint = 0;
function setColumnWidthsAndAlignments()
var myWidths=[29, 23, 13, 13, 13, 13];
var myAlignments=["leftAlign","leftAlign","centerAlign","centerAlign","rightAlign","rightAlign"];
var numberOfColumns=myTable.columns.count();
for (c=0;c<numberOfColumns;c++)
myTable.columns[c].width=myWidths[c];
myTable.columns[c].cells.everyItem().texts.everyItem().justification=Justification.myAlignments[c];
function setRowHeightsAndInsets()
myTable.rows.everyItem().minimumHeight=1.058;
myInset=0.5;
myTable.rows.everyItem().topInset=myInset;
myTable.rows.everyItem().bottomInset=myInset;
You'd probably have more luck trying something like:
var myAlignments = [Justification.LEFT_ALIGN, Justification.LEFT_ALIGN,
Justification.CENTER_ALIGN etc.]
and then in the other line: ...texts.everyItem().justification =
myAlignments[c];
Alternatively, you could try keeping it as you have it, but perhaps
changing it to this:
texts.everyItem().justification = eval("Justification."+myAlignments[c]);...
which just creates a string and then runs it with eval.
At any rate, the problem as I see it with what you have is that you
myAlignments is an array of strings, and you cannot access a property of
an object (in this case Justification) with a dot+string. When you put
"Justification.leftAlign" and it works, I think that's because leftAlign
isn't acting as a string -- it's simply a property of the Justification
object.
Ariel
Similar Messages
-
How to swap column values using variable in sql?
Hi,
I have a table and i want to swap two column values using variable
please help meHi,
Let us assume that the DeptNAME and DeptNo columns are of type VARCHAR2. However, DeptNO column is VARCHAR2(10) and DeptNAMe is VARCHAR2(100).
First of all DeptNo column needs to be modified to be 100.
i) ALTER TABLE DEPT MODIFY DEPTNO VARCHAR2(100);
Secondly, you will swap DEPTNAME and DEPTNO values using the SQL as follows:
ii) update dept t1
set deptname = (select deptno from dept2 t2 where t1.deptno = t2.deptno),
deptno = (select deptname from dept2 t2 where t1.deptno = t2.deptno);
Now, finally you want the deptname columns to be VARCHAR2(10)
iii) ALTER TABLE DEPT MODIFY DEPTNAME VARCHAR2(10).
If DEPTNO is a NUMBER column, you cannot alter the datatype unless the table is empty; in that case the whole swapping requirement would be moot.
Trinath Somanchi,
( http://www.myospages.com ) -
Usage of sequence for uploading data into tables(column store) using CSV
How to make use of sequence when data is uploaded into table(column store) with the CSV file ?
Hi Sharada,
You may have to follow the below steps:
1) To load the data from flat file to a Staging table using IMPORT command
2) You have to call the procedure to load the data further into final Table.
a) Have a look on this procedure to load data :
SAP HANA: Generic Procedure using Arrays to Load delta data into Tables
b) See my reply on the syntax on how to use "Sequence"
Auto-Incrementor in stored procedure!
You will have to ensure that you frame your insert query in such a way to have the sequence number in the target table.
Regards,
Krishna Tangudu -
Controlling Table Column visibility through Program
Hi Experts
We have custom WD Java applications developed in NW 7.0 which we have now migrated to NW 7.3.
The visibility property of the columns are bound to the Context attributes. In the application, we are controlling the visibility of the Table columns by setting the values of context attributes.
However, i could see that even though the visibility property is set as "NONE", by printing it on screen, those particular columns are visible.
Am I missing something?? Do we need to take care of something or is any other property needs to be set??
Thanks in advance..
Regards,
DeepakOK, starting at the lowest level is getting the column selected, since we need to select the correct column
before selecting the first cell in the column to rename (a separate funciton?) and then the remaining cells
in the column (another function)? Once these two functions are done, the rest would be like the example in the
the Frame book, since then you would have a function select only the tables that have a certain name and then
all the files in the book.
#target framemaker
// !! first, click on table
var doc=app.ActiveDoc;
//Get the table containing the insertion point
var tbl=doc.SelectedTbl;
//Get the first cell in the first row
var cell=tbl.FirstRowInTbl.FirstCellInRow;
var colNum=3;
for (var i=1; i<colNum; i+=1){
cell=cell.NextCellInRow;
while (cell.ObjectValid()){
var pgf=cell.FirstPgf;
alert (pgf.Name);
alert(cell);
cell=cell.CellBelowInCol;// Move down to next cell -
Hyperlink in UI table column without using leadselect
Hi All,
I am using hyperlink for a column in my UI table element. When i click the hyperlink, I am opening a pop-up screen.
The problem is, the pop-up is opening only after i leadselect a row and then i click the hyperlink.
But i want the hyperlink click to open the pop-up without clicking leadselect.
How to achieve this?
Please help me as soon as possible.
Thanks a lot.Hi,
First disable the leadselection for the table.
Implement the action for Hyperlink check the box transfer UI events. When you do this, you will get the
index that is clicked in the WDEVENT parameters. Using this index, you can open the popup.
Check the wdr_test_table for the same under TABLE CELL EDITORS.
Regards,
Lekha. -
Select members from Row/ column context using variables.
Does EPMA Calculation Manager provide the facility of using any kind of variable which will enable to select members dynamically from row/ column in a Planning webform as we use member variable to select members from Page/ POV?
Please suggest. Thanks in advanceHi,
Check out Environment/Replacement Variables in Calc Manager, where replacement variable can be used as RTP.
Cheers...!! -
Controlling Table Columns Case Senstivity
Hello Guys,
I am failry new to Oracle and I have a question. I created a table with the following script
create table Employee
Name varchar2(30),
Num number(38,0)
Now if I do a select * from Employee i get the column names as 'NAME' and 'NUM'. Is there a way for me to actually see them with the created names like 'Name' and 'Num'. Oracle by default seems to convert everything into Upper Case unless if i embed them in quotes which i dont want to
Is there a way, Please suggest
thanks
prashYou cannot do this permanently. Non-quoted identifiers are always uppercased before being stored in the data dictionary. If you just need original names in query results use aliases:
select name "Name", num "Num" from Employee-- Sergiusz -
Use SQL to INSERT a record into an Access table and populate using variables
I am having difficulties with the following code:
'Get my username
UserNameWindows = GetUserName
'Assemble my name and request corrections
MsgBoxTitle = "What name do you want to use?"
NewDefault = Replace(UserNameWindows, ".", " ")
NewDefault = StrConv(NewDefault, vbProperCase)
MyValue = InputBox(Message, MsgBoxTitle, NewDefault)
RealName = MyValue
'Assemble your email address
MsgBoxTitle = "What is your email address?"
NewDefault = UserNameWindows & "@calibreglobal.com.au"
MyValue = InputBox(Message, MsgBoxTitle, NewDefault)
EmailAddress = MyValue
MsgBox "Your UserNameWindows value is " & UserNameWindows & "."
'Insert UserNameWindows into the tblAuthorisedPeople table
strSQL = "INSERT INTO tblAuthorisedPeople (Person, RealName, EmailAddress) VALUES (" & UserNameWindows & ",""" & RealName & """, """ & EmailAddress & """)"
DoCmd.RunSQL (strSQL)
It asks me to enter the value for the Person field into a dialogue box instead of using the value of UserNameWindows.
After entry, it accepts the other values and enters the record correctly.
I have also tried this SQL string without success
strSQL = "INSERT INTO tblAuthorisedPeople (Person, RealName, EmailAddress) VALUES (" & Forms!frmCreateNew!UserNameWindows & ",""" & RealName & """, """ & EmailAddress & """)"
Any comments?
Barry CuthbertsonFound the error. I had used the rules for the syntax from a web forum reply which appears to have been incorrect!
strSQL = "INSERT INTO tblAuthorisedPeople (Person, RealName, EmailAddress) VALUES (""" & UserNameWindows & """,""" & RealName & """, """ & EmailAddress &
This seems to be working well as the moment
All finished.
Barry GC
-
Controlling position of thumbnails using variables
Hi the code is attached for reference.
This action script controls a photo gallery
I need to modify the dimensions of the movie clip. I was able
to change the position of where the main image clips and also where
the thumbnails appear at the starting point, however when the
scroll pane starts to move to left and right I cannot control it's
position any longer. I need to show the thumbnails about 500 from
the left of the flash and make sure it will stay this way. Right
now, when I mouse over the scroll pane the thumbnails start moving
to the left all the way to about 4 pixels from the left of the
movie.
Can someone help. I am providing links for the difference
between movie clips. Any help is super appreciated.
Before
changing movie dimensions
After
changing movie dimensionscool thank u so much! I've tried to change the X and Y on the
code that is attached to the frame, but its still loading in in the
same place. Take it its here that you set the positions? whats the
100 value that is attached to the button? -
Formel Variable - how to fill with Customer Exit from control table
Hello Experts,
I have create in BEx-Analyser a formel Variable ZEXRATE1 filled through Customer Exit. In BW I had a "control tabel" with keyfigures.
In the query definition I have include 0FISCPER, 0FISCVARNT and 0VTYPE. This
are the keys which should give the values for the selectstatement to select my keyfigure from the "control table" to fill ZEXRATE1.
If it possible to do with Customer Exit (CMOD -> RSR00001 -> ZXRSRU01) or do I have to implement a Bapi. Perhaps someone can give me a code example.
Regards DieterHi,
Code may look like this
WHEN 'ZEXRATE1'.
check i_step = 2.
LOOP AT I_T_VAR_RANGE INTO L_S_RANGE.
CASE L_S_RANGE-IOBJNM.
WHEN 'ZFISCPER'. GV_ZFISCPER = L_S_RANGE-LOW.
WHEN 'ZFISCVARNT'. GV_ZFISCVARNT = L_S_RANGE-LOW.
WHEN 'ZVTYPE'. GV_ZVTYPE = L_S_RANGE-LOW.
ENDCASE.
ENDLOOP.
SELECT SINGLE RATE into INTO GV_RATE
FROM ZTABLE
WHERE 0FISCPER = GV_ZFISCPER
AND 0FISCVARNT = GV_ZFISCVARNT
AND 0VTYPE = GV_ZVTYPE .
Assumptions : ZTABLE name of control table
ZFISCPER name of variable represents fiscal period
'ZFISCVARNT' name of variable representing fiscal year variant
'ZVTYPE'. name of variable representing value type
Hope that helps.
Regards
Mr Kapadia
Assigning points is the way to say thanks in SDN. -
Using variables to specify tables and columns in a function
All,
I'm trying to create a function to select a random table, random column, random row, and return the data. I'm not quite sure how to use the table_name once I have it stored in the variable and I'm hoping someone can help.
Here is the code:
create or replace function sknddstr (asdf in varchar2)
return varchar2
is
v_table varchar2(50);
v_column varchar2(50);
v_data varchar2(50);
v_return varchar2(160);
begin
select asdf.table_name into v_table
from dual
, (select table_name
from user_tables
where table_name not like 'TEMP%'
order by dbms_random.random) asdf
where rownum < 2;
select fdsa.column_name into v_column
from dual
, (select column_name
from user_tab_cols
where table_name = v_table
and nullable = 'Y'
order by dbms_random.random) fdsa
where rownum < 2;
select v_column into v_data
from dual
, (select v_column
from v_table
order by dbms_random.random)
where rownum < 2;
select v_table || ' | ' || v_column || ' | ' || v_data into v_return
from dual;
return v_return;
end;
Any suggestions? BTW, I know I don't use the IN asdf, but I'm not sure how to create a function with no parameters.
Thanks again!You need to use dynamic SQL whenever you substitute object names (table, column, etc.) at runtime. I would suggest something like (note I have changed the filters to match my data):
sql>create or replace function f_random_data
2 return varchar2
3 is
4 v_table_name user_tab_columns.table_name%type;
5 v_column_name user_tab_columns.column_name%type;
6 v_data varchar2(4000);
7 begin
8 select table_name, column_name
9 into v_table_name, v_column_name
10 from (select table_name, column_name
11 from user_tab_columns
12 where table_name = (select table_name
13 from (select table_name
14 from user_tables
15 where table_name in ('EMP', 'DEPT')
16 order by dbms_random.random)
17 where rownum <= 1)
18 -- and nullable = 'Y'
19 order by dbms_random.random)
20 where rownum <= 1;
21
22 execute immediate
23 'select *' ||
24 ' from (select ' || v_column_name ||
25 ' from ' || v_table_name ||
26 ' order by dbms_random.random)' ||
27 ' where rownum <= 1'
28 into v_data;
29
30 return (v_table_name || '|' || v_column_name || '|' || v_data);
31 end;
32 /
Function created.
sql>select f_random_data from dual;
F_RANDOM_DATA
EMP|COMM|500
1 row selected.
sql>/
F_RANDOM_DATA
DEPT|DNAME|SALES
1 row selected.
sql>/
F_RANDOM_DATA
DEPT|DEPTNO|40
1 row selected.
sql>/
F_RANDOM_DATA
EMP|ENAME|SCOTT
1 row selected.
sql>/
F_RANDOM_DATA
DEPT|DNAME|OPERATIONS
1 row selected. -
Vertical Alignment in table columns
Using JHeadstart 10.1.3.4.
Different display types are differently positioned in table columns. Single text seems vertically centered; text fields with multiple lines are vertically aligned at the top of a table column; vertical radio buttons are vertically aligned at the bottom of a table column. The resulting display is quite messy.
I have not found any formating option in JHeadStart that allows for controlling vertical alignment. Am I a missing something?
If JHeadStart 10g does not support controlling vertical alignment directly, how should this be handled? Does JHeadStart 11g add such vertical alignment support?Hello,
If you need anything special considering vertical alignment in tables, you can simply perform that in the resulting JSPX page. In other words, just alter the JSPX file to whatever you need.
Save your customizations in JHeadstart using velocity templates, so your page is regenerateable while keeping your changes. See the JHeadstart Developers Guide on how to change such customizations in the templates.
Also in release 11 there is no vertical alignment (yet); I suppose because for most tables, each row just has a single line and vertical alignment is therefore not needed. However, I have put it on the wish-list, so we will check on it later. Thanks!
Regards,
Evert-Jan de Bruin
JHeadstart Team -
How i pass table column value to string variable or return to java applete
Hi Master,
How do I pass a table column value into string variable. See my code below:
import java.sql.*;
public class Waheed {
public Waheed() {
public static void main (String args [])
String s = "9 23 45.4 56.7";
System.out.println ("going for connection");
// DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn =
DriverManager.getConnection("jdbc:oracle:thin:@fahim:1521:aamir","muhammad","mfa786");
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select accid from accbal");
System.out.println ("going for connection");
while (rset.next())
s= rset.getString("accid"); this line give me error
System.out.println (rset.getString("accid"));
System.out.println (s);
catch(Exception e){
e.printStackTrace();
This line give me an error:
s= rset.getString("accid");
s is string variable
Plese give me an idea how I can pass accid in s variable.
Thanks.
AamirSee the code sample in the following thread (try using upeercase).
JDBC connection
Kuassi -
Alignment on a specific character in an af:table column
Hello,
I have an af:table with columns containing vehicle kilometer counter, average speeds, running hours... These values may contain décimals, but not always. And I would like these values to be aligned on the decimal separator (. or ,) in the table column. Could you tell me how to do this?
The only solution I have found now is using text-align=right and using minFractionDigits/maxFractionDigits. Working, but not very attractive...
Thank you for your help
StephaneThe approach used by you - seems to be fine for me.
1) For aligning the text to the right, you would need to use the text-align:right as an inlineStyle property for the column.
2) For formatting of numbers, you can use the specify the pattern directly-
<af:column sortProperty="Salary" sortable="false"
headerText="#{bindings.Employees.hints.Salary.label}"
id="resId1c8" inlineStyle="text-align:right">
<af:outputText value="#{row.Salary}" id="ot8">
<af:convertNumber groupingUsed="true" pattern="###,###,###.000"/>
</af:outputText>
</af:column>
Thanks,
Navaneeth -
How do I refresh a table with a bind variable using a return listener?
JDev 11.1.2.1.0.
I am trying to refresh a table with a bind variable after a record is added.
The main page has a button which, on click, calls a task flow as an inline document. This popup task flow allows the user to insert a record. It has its own transaction and does not share data controls.
Upon task flow return, the calling button's return dialog listener is invoked which should allow the user to see the newly created item in the table. The returnListener code:
// retrieve the bind variable and clear it of any values used to filter the table results
BindingContainer bindings = ADFUtils.getBindings();
AttributeBinding attr = (AttributeBinding)bindings.getControlBinding("pBpKey");
attr.setInputValue("");
// execute the table so it returns all rows
OperationBinding operationBinding = bindings.getOperationBinding("ExecuteWithParams");
operationBinding.execute();
// set the table's iterator to the newly created row
DCIteratorBinding iter = (DCIteratorBinding) bindings.get("AllCustomersIterator");
Object customerId = AdfFacesContext.getCurrentInstance().getPageFlowScope().get("newCustomerId");
iter.setCurrentRowWithKeyValue((String)customerId);
// refresh the page
AdfFacesContext.getCurrentInstance().addPartialTarget(this.getFilterText());
AdfFacesContext.getCurrentInstance().addPartialTarget(this.getCustomerTable());But the table does not refresh ... The bind variable's inputText component is empty. The table flickers as if it updates. But no new values are displayed, just the ones that were previously filtered or shown.
I can do the EXACT SAME code in a button's actionListener that I click manually and the table will refresh fine. I'm really confused and have spent almost all day on this problem.
WillBoth options invoke the create new record task flow. The first method runs the "reset" code shown above through the calling button's returnListener once the task flow is complete. The second method is simply a button which, after the new record is added and the task flow returns, runs the "reset" code by my clicking it manually.
I'm thinking that the returnListener code runs before some kind of automatic ppr happens on the table. I think this because the table contents flicker to show all customers (like I intend) but then goes back to displaying the restricted contents a split second later.
Yes, the table is in the page that invokes the taskflow.
Here are some pictures:
http://williverstravels.com/JDev/Forums/Threads/2337410/Step1.jpg
http://williverstravels.com/JDev/Forums/Threads/2337410/Step2.jpg
http://williverstravels.com/JDev/Forums/Threads/2337410/Step3.jpg
Step1 - invoke new record task flow
Step2 - enter data and click Finish
Step3 - bind parameter / table filter cleared. Table flickers with all values. Table reverts to previously filterd values.
Maybe you are looking for
-
How do I get my MacBook pro to play on my tv?
How do I get my MacBook pro to work on my tv. I have the correct cables to connect it. I just keep getting the mac screensaver showing?
-
Hi, I am Trying to automate the Report Generation by using the VB script, I can do all the calculation in the Excel sheet but how I can implement the same in the Vb script. I want to take a mean of 2 cell in X channel and output the sum in channel
-
How to write CRM Program.........
Dear Frnds, I am familiar with ABAP but now i want to go with CRM but i have no idea about how to write simple program. Is it with scripting and abap code for run simple program.. which are the transaction code to write program and execute. pls make
-
Not working t:inputCalendar in facelets
This is my code : ====================================================== <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xm
-
POI: HSSFCellStyle odd results
The function below works just fine <p> public short addColumnHeader( int rId, String name ) {</p> HSSFRow row = sheet.getRow( rId ); HSSFCell firstCell = row.getCell((short)0); HSSFCellStyle headerStyle = firstCell.getCellSt yle();