• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Duplicate table row

Contributor ,
Aug 31, 2016 Aug 31, 2016

Copy link to clipboard

Copied

Dear Friend,

I need your help!

How to duplicate in the table row? I was try and search to forum, but i have not got single solution. Also, i have place my code and screenshot below:

please suggest me friends.

 

  var curDoc = app.documents[0]; 

  var allTables = curDoc.stories.everyItem().tables.everyItem().getElements(); 

  var nTables = allTables.length; 

  var testID = 0;

  for (var t = 0; t < nTables; t++) { 

    var curTable = allTables

    var allRows = curTable.rows; 

    var nRows   = allRows.length; 

     

    for (var r = 0; r < nRows; r++) { 

      var curRow = allRows

      var iP = curRow.cells[0].insertionPoints[0]; 

      var parTFrameID = iP.parentTextFrames[0].id; 

 

      if (testID != 0 && testID != parTFrameID) { 

        var appliedStyle = allRows[r-1].cells.everyItem().appliedCellStyle = "TBLR";

        var addRow = allRows.add(LocationOptions.BEFORE, allRows[r+0]);

//************************I have missing some duplicate code here******************************

//************************Help Need******************************       

       

      } 

    testID = parTFrameID; 

    } 

  } 

screenshot here:

DDD.png

Thanks in Advance

KS

TOPICS
Scripting

Views

1.1K

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
Guide ,
Aug 31, 2016 Aug 31, 2016

Copy link to clipboard

Copied

It looks like you can use header option available in table menu

Votes

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
LEGEND ,
Aug 31, 2016 Aug 31, 2016

Copy link to clipboard

Copied

Nope! Table Title is included in the first cells line! 

Votes

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
Guide ,
Aug 31, 2016 Aug 31, 2016

Copy link to clipboard

Copied

Ah.. I missed

Votes

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 ,
Aug 31, 2016 Aug 31, 2016

Copy link to clipboard

Copied

First of all, don’t call it 'my code' if it is not yours … 😉

Second:

You try to add rows to rows, but in the UI you would add rows to the current table.

main();

function main() {

var curDoc = app.documents[0];

var allTables = curDoc.stories.everyItem().tables.everyItem().getElements();

var nTables = allTables.length;

var testID = 0;

for (var t = 0; t < nTables; t++) {

  var curTable = allTables;

  var allRows = curTable.rows;

  var nRows   = allRows.length;

  var subheaderContents = allRows[1].contents;

 

  for (var r = 0; r < nRows; r++) {

    var curRow = allRows;

    var iP = curRow.cells[0].insertionPoints[0];

    var parTFrameID = iP.parentTextFrames[0].id;

    if (testID != 0 && testID != parTFrameID) {

      var c = allRows[r-1].cells.everyItem();

      var subheaderRow = curTable.rows.add(LocationOptions.BEFORE, curRow);

      subheaderRow.contents = subheaderContents;

    }

    testID = parTFrameID;

  }

}

}

Votes

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
LEGEND ,
Aug 31, 2016 Aug 31, 2016

Copy link to clipboard

Copied

LATEST

Aha! … "Nobody forces you but, if you give me, it belongs to me and it becomes mine! So it's mine!" Simply logical! 

As we say in French: "Donné, c'est donné ! Reprendre, c'est volé !" 

Votes

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