Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


How to select a row in a table from cursor position

Advocate ,
Mar 12, 2017 Mar 12, 2017

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.

TOPICS
Scripting

Views

332

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guru , Mar 12, 2017 Mar 12, 2017
Hi Jean-Claudefunction 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();HTHTrevor

Likes

Translate

Translate
Guru ,
Mar 12, 2017 Mar 12, 2017

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 12, 2017 Mar 12, 2017

Copy link to clipboard

Copied

Thanks Trevor... That did it!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 19, 2021 Nov 19, 2021

Copy link to clipboard

Copied

Please @Trevor: Can this script modified to avoid selecting the header cell (in the same column)?

Thanks in Advance

Best
M.Hasanain

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 20, 2021 Nov 20, 2021

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();

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 20, 2021 Nov 20, 2021

Copy link to clipboard

Copied

Thanks  a lot @brianp311

Best
M.Hasanain

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 20, 2021 Nov 20, 2021

Copy link to clipboard

Copied

Please @brianp311  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

Best
M.Hasanain

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 20, 2021 Nov 20, 2021

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). 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 20, 2021 Nov 20, 2021

Copy link to clipboard

Copied

LATEST

Thanks a lot @brianp311 

Best
M.Hasanain

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines