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

How do I change the table's first row to a Heading row if it contains pgfs with tblHead tags

New Here ,
May 06, 2014 May 06, 2014

Copy link to clipboard

Copied

So far, I have the following in a JavaScript:

if (tbl.FirstRowInTbl.FirstCellInRow.FirstPgf.PgfFmt.Name === "tblHead")

        {

            if (tbl.FirstRowInTbl.RowType === 1)

                //1 is Constants.FV_ROW_BODY

                tbl.FirstRowInTbl.RowType = 0;

                // 0 is Constants.FV_ROW_HEADING

            else

                continue;

         }

        else

            continue;

This does not work. I'm not comfortable with tbl.FirstRowInTbl.FirstCellInRow.FirstPgf.PgfFmt.Name.

It is clearly wrong. How would I indicate I want to determine the tag of the first paragraph in the first row?

Any help is very much appreciated!

Thanks,

Ruth

TOPICS
Scripting

Views

808

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

Community Expert , May 07, 2014 May 07, 2014

Ruth, here is a function that will convert body rows to heading rows in a table. Please let me know if you have any questions or comments. -Rick

#target framemaker

var doc = app.ActiveDoc;

// Set a variable for the selected table.

var tbl = doc.SelectedTbl;

// Convert the first body row to a heading row.

bodyToHeadingRow (tbl, 1, doc);

function bodyToHeadingRow (tbl, num, doc) {

   

    var row = 0;

   

    // Select the top "num" rows in the table.

    tbl.MakeTblSelection (0, num - 1, 0,

...

Votes

Translate

Translate
Advocate ,
May 06, 2014 May 06, 2014

Copy link to clipboard

Copied

Ruth,

You will have to develop this step by step. You might assume that something is 'clearly' wrong, but you only know when you let the script tell you what it found. So either use the debugger and look at the values in the data browser, or insert an alert to see what the actual value is that the script found. Then proceed, small step by small step.

In general, I am not a big fan of those long strings of properties like the one you use in your if statement. Try breaking it up in smaller pieces, use variables to hold the values and objects, and either alert ( varname ) or Console ( varname ) to see what their values are at given points in the script.

Good luck

Jang

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
Mentor ,
May 07, 2014 May 07, 2014

Copy link to clipboard

Copied

Hi Ruth,

One big problem with your script is that the RowType property is read-only. So, you can't just change a row type by setting a new value. You have to insert a new heading row, copy the data over from the body row, then delete the body row. This is a lot more complicated obviously, but it follows the FrameMaker table model and it is consistent with row management within the GUI.

The line of code that you claim is "clearly wrong" doesn't look wrong to me, at a glance. If you aren't sure if it is locating what you want, put some extra code in there to test, like an alert() or confirm() box with each match to see what it is actually doing. Jang suggests the debugger as well, although be warned that the ES toolkit debug environment is not for the faint of heart.

Russ

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
New Here ,
May 07, 2014 May 07, 2014

Copy link to clipboard

Copied

Russ:

Thank you for this information. I’ll see if I can take those actions you recommend… that’s exactly what I will have to do by hand if I can’t get the script to do it! ☺

Ruth

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
Community Expert ,
May 07, 2014 May 07, 2014

Copy link to clipboard

Copied

Ruth, here is a function that will convert body rows to heading rows in a table. Please let me know if you have any questions or comments. -Rick

#target framemaker

var doc = app.ActiveDoc;

// Set a variable for the selected table.

var tbl = doc.SelectedTbl;

// Convert the first body row to a heading row.

bodyToHeadingRow (tbl, 1, doc);

function bodyToHeadingRow (tbl, num, doc) {

   

    var row = 0;

   

    // Select the top "num" rows in the table.

    tbl.MakeTblSelection (0, num - 1, 0, tbl.TblNumCols - 1);

    // Push the current clipboard contents and cut the selected rows.

    PushClipboard ();

    doc.Cut (Constants.FF_CUT_TBL_CELLS);

    // Add "num" number of heading rows to the table.

    row = tbl.FirstRowInTbl;

    row.AddRows (Constants.FV_Heading, num);

    // Select the new heading rows.

    tbl.MakeTblSelection (0, num - 1, 0, tbl.TblNumCols - 1);

    // Paste the rows from the clipboard into the new heading rows.

    doc.Paste (Constants.FF_REPLACE_CELLS);

    // Restore the clipboard contents.

    PopClipboard();

   

}

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
New Here ,
May 07, 2014 May 07, 2014

Copy link to clipboard

Copied

Rick:

Thanks! I adapted what you sent me (I was partially there, but making it very hard on myself, as I didn’t think in terms of working with the doc object and was trying to do everything at the cell level, rather than at the table level. Your approach is much better.

I needed only to make the top row into a heading row, so here is my resulting function (it may have a few more variables than required...). I’m not sure if it is absolutely required that the text but copied to the clipboard, then cut, but I’m doing both to be on the safe side. When I cut rows, don’t they always go on the clipboard? That’s what the documentation says under the Cut method… anyway, it’s good to be sure ☺

I still have to test it, but it looks good at this point. Thank you so much!

Ruth

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
Community Expert ,
May 07, 2014 May 07, 2014

Copy link to clipboard

Copied

Hi Ruth, Thanks for the feedback. Please mark my post as the correct answer when you get a chance. Thanks. -Rick

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
New Here ,
May 08, 2014 May 08, 2014

Copy link to clipboard

Copied

Rick:

Not sure how to mark your post. My reply said I adapted your solution to come up with mine, but I’m new to using this forum, so please LMK how to mark your post.

Ruth

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
Advocate ,
May 08, 2014 May 08, 2014

Copy link to clipboard

Copied

Hi Ruth (and Rick),

Rick is referring to the old forum software, where an answer could be marked as Correct or Helpful. This would gain the person who posted the answer 10 or 5 points, and higher points give more esteem. WIth the new software that Adobe has activated, the correct and helpful markers are no longer there. There is a 5-star rating, but that appears only on the original question, so it is unclear how to rate a particular answer, Possibly this will not be available anymore, or some 'actions' might be made available later. For the moment, I guess there are no more points to be received, just virtual karma to be found.

Kind regards

Jang

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 ,
May 08, 2014 May 08, 2014

Copy link to clipboard

Copied

The main purposes of marking an answer correct is to let others know that a solution exists if they are searching for an answer to the same or similar issue/problem. When one views the Discussion list, questions that are marked answered show with a green bubble and a check mark. Unanswered questions just stay blue with a ? mark inside the bubble and non-question messages (announcement or info) just show as grey bubbles.

discussion_marks.png

Points are still awarded in the [explitive deleted] social scheme at the core of the new version of the Jive software.

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
Community Expert ,
May 08, 2014 May 08, 2014

Copy link to clipboard

Copied

Hi Arnis, I guess the question is, can you still mark an answer as correct with the new software, and if so, how do you do it? Thanks. Rick

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 ,
May 08, 2014 May 08, 2014

Copy link to clipboard

Copied

In a thread/discussion that hasn't been "answered" there should be an icon link at the end of every message:

Jive_correect_answer.pngas in:

Rick_message.png

If you're not seeing these (you have be viewing in a web browser), please let me know.

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
New Here ,
May 08, 2014 May 08, 2014

Copy link to clipboard

Copied

Arnis:

I did not any of these icons, even though I am viewing the forum in Firefox. Looks like you have marked Rick’s answer as the correct answer for me.

Thanks ☺

If you know why I’m not seeing the icons and what I should be doing differently, please feel free to advise me. ☺

Thanks,

Ruth

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 ,
May 08, 2014 May 08, 2014

Copy link to clipboard

Copied

Hi Ruth,

Hmmm, I see it in Chrome, FireFox and IE and the message isn't marked as answered yet [see top of the thread in the original posting].

Ok, I just tried a non-moderator account and the icons aren't there. I have to check into this to see if this is broken for regular users or how this is supposed to be handled now. Thanks for letting me know that you can't see them.

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 ,
May 08, 2014 May 08, 2014

Copy link to clipboard

Copied

Ruth,

It looks like a bug [another one in a long list of]  in the new implementation. The original poster along with the moderator are supposed to be able to see the "Correct Answer" button.

The "Helpful" marking that everyone saw before is gone [for] now.

[I'll mark Rick's answer as correct]

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 ,
May 08, 2014 May 08, 2014

Copy link to clipboard

Copied

Ruth (and anybody else),

Can you please check any other discussions that you've started and let me know if you can see the Correct Answer button in the thread messages if the discussion hasn't already been marked as having a correec answer.

Other OP's (original posters) are seeing them in other Forums.

If you don't see any of the Correct Answer buttons, please let me know the details of the browser that you're using.

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
New Here ,
May 09, 2014 May 09, 2014

Copy link to clipboard

Copied

Arnis:

This is the first discussion I’ve ever started, so I’m afraid there are no other discussions to check…

I can try starting another discussion and see what happens. Give me a moment to come up with a discussion point… ☺

Ruth

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
Advocate ,
May 09, 2014 May 09, 2014

Copy link to clipboard

Copied

Hey, it worked ! Now we can get points again, trying to get to the top of the list of MVPs on the forum. After all, we're only in it for the fame, right ?

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 ,
May 09, 2014 May 09, 2014

Copy link to clipboard

Copied

LATEST

Ruth,

Check to see if you have any javascript blockers enabled in your browser. These apparently will interfere with a lot of the Jive Forum software operations.

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
Community Expert ,
May 07, 2014 May 07, 2014

Copy link to clipboard

Copied

Hi Ruth,

This:

if (tbl.FirstRowInTbl.FirstCellInRow.FirstPgf.PgfFmt.Name === "tblHead")


should be


if (tbl.FirstRowInTbl.FirstCellInRow.FirstPgf.Name === "tblHead")


I agree with Jang; sometimes having long property strings can be hard to follow and debug. You should at least capture the row in a variable since you have to work with it later in the script.


var row = tbl.FirstRowInTbl;

var cell = row.FirstCellInRow;

if (cell.FirstPgf.Name === "tblHead")

...


Russ is right, you can't just change the RowType because it is read only. If I have time later I will post the code that shows how to do this.


Rick

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