Copy link to clipboard
Copied
Hi,
This is probably simple, but I can’t find how.
I need a snippet that will select and entire row from the location of the insertion of the cursor. Similar to the InDesign «Select Row» command.
Sorry for the newbie question.
Hi Jean-Claude
function selectRow(s) {
s = s || app.selection[0];
if (!s) {
return 'no selection';
}
while (s.constructor !== Cell){
s = s.parent;
if (s.constructor === Application) {
return 'no cell found';
}
}
s.parentRow.select();
}
selectRow();
HTH
Trevor
Copy link to clipboard
Copied
Hi Jean-Claude
function selectRow(s) {
s = s || app.selection[0];
if (!s) {
return 'no selection';
}
while (s.constructor !== Cell){
s = s.parent;
if (s.constructor === Application) {
return 'no cell found';
}
}
s.parentRow.select();
}
selectRow();
HTH
Trevor
Copy link to clipboard
Copied
Thanks Trevor... That did it!
Copy link to clipboard
Copied
Please @Trevor: Can this script modified to avoid selecting the header cell (in the same column)?
Thanks in Advance
Copy link to clipboard
Copied
To be clear, you want to select a column, not a row, but exclude header cells? If so, try this:
function selectColumn(s) {
s = s || app.selection[0];
if (!s) {
return 'no selection';
}
while (s.constructor !== Cell){
s = s.parent;
if (s.constructor === Application) {
return 'no cell found';
}
}
var target = s.parentColumn;
var pccells = target.cells;
for (var i = 0; i < pccells.length; i++) {
if (pccells[i].rowType !== RowTypes.HEADER_ROW) {
pccells[i].select();
}
}
}
selectColumn();
Copy link to clipboard
Copied
Thanks a lot @brian_p_dts
Copy link to clipboard
Copied
Please @brian_p_dts What is the Opposite Command of (Select()), i searched the DOM many times but didnt find anything, just deselect for item pages, but i mean deselect cells opposite of select();
Thanks
Copy link to clipboard
Copied
app.selection = null will remove all selections. The select() method has optional arguments that you can pass to it to replace the existing selection (default is to add to selection).
Copy link to clipboard
Copied
Thanks a lot @brian_p_dts
Copy link to clipboard
Copied
Suppose, I don't have a table header row yet.
I am going to select multiple rows and convert them to table headers.
How do I get the rows that are currently selected with the mouse?
selectedRows =
Copy link to clipboard
Copied
Hi @dublove
try this :
DoConvert();
function DoConvert(){
var myTable = app.selection[0]; // Get the selected top cells
var myRows = myTable.rows; // Get all table rows in selection
// Loop through each row in the table
for (var i = 0; i < myRows.length; i++) {
// Check if the row is a body row and convert it to a header row
if (myRows[i].rowType === RowTypes.BODY_ROW) {
myRows[i].rowType = RowTypes.HEADER_ROW;
}
}
alert("Body rows converted to header rows successfully.");
}