-
1. Re: [JS] Table RowTypes.BODY_ROW
pkahrel Jan 25, 2014 3:35 AM (in response to Philippe Ruelle)Header rows have to be converted last to first, which is what we'd expect. But bizarrely, you have to convert footer rows from first to last. So header rows and footer rows need to be converted in separate loops:
tetes = monTableau.headerRowCount; for (y = tetes-1; y >= 0; y--) { monTableau.rows[y].rowType = RowTypes.BODY_ROW; } start = monTableau.bodyRowCount; stop = start+monTableau.footerRowCount; for (y = start; y < stop; y++) { monTableau.rows[y].rowType = RowTypes.BODY_ROW; }Peter
-
2. Re: [JS] Table RowTypes.BODY_ROW
Harbs. Jan 27, 2014 3:36 AM (in response to pkahrel)Peter Kahrel wrote:
But bizarrely, you have to convert footer rows from first to last...
Makes sense to me. You can't have body rows above header rows or below footer rows.
Harbs
-
3. Re: [JS] Table RowTypes.BODY_ROW
pkahrel Jan 27, 2014 5:53 AM (in response to Harbs.)> Makes sense to me. You can't have body rows above header rows or below footer rows.
Just testing
Ok, not so bizarre, you're absolutely right.
Peter
-
4. Re: [JS] Table RowTypes.BODY_ROW
Marc Autret Jan 27, 2014 10:22 AM (in response to pkahrel)What about:
monTableau.rows.everyItem().properties = {rowType: RowTypes.BODY_ROW};?
@+
Marc
[EDIT: Doesn't seem to work as expected. Weird…]
-
5. Re: [JS] Table RowTypes.BODY_ROW
Philippe Ruelle Jan 27, 2014 10:49 AM (in response to Marc Autret)Hello/Bonsoir Marc,
I just did a little test with your command line:je vien de faire un petit test avec ta ligne de commande :
First pass:Première passe :
$.writeln ('AV :' +monTableau.headerRowCount + ' headerRow'); // conte le nombre de ligne d'en-tête
$.writeln ('AV :' + monTableau.footerRowCount + ' footerRow'); // conte le nombre de ligne de pied de page
monTableau.rows.everyItem().properties = {rowType: RowTypes.BODY_ROW};
$.writeln ('AP :' +monTableau.headerRowCount+ ' headerRow'); // conte le nombre de ligne d'en-tête
$.writeln ('AP :' +monTableau.footerRowCount + ' footerRow'); // conte le nombre de ligne de pied de page
Result: (biza)
Résulta : (biza)
AV :2 headerRow
AV :2 footerRow
AP :1 headerRow
AP : 0 footerRow
second pass :
AV :1 headerRow
AV : 0 footerRow
AP : 0 headerRow
AP : 0 footerRow
@Peter
$.writeln ('AV :' +monTableau.headerRowCount + ' headerRow'); // conte le nombre de ligne d'en-tête
$.writeln ('AV :' + monTableau.footerRowCount + ' footerRow'); // conte le nombre de ligne de pied de page
tetes = monTableau.headerRowCount;
for (y = tetes-1; y >= 0; y--) {
monTableau.rows[y].rowType = RowTypes.BODY_ROW;
}
start = monTableau.bodyRowCount;
for (y = start; y < (monTableau.rows.length); y++) { // petit modification
monTableau.rows[y].rowType = RowTypes.BODY_ROW;
}
$.writeln ('AP :' +monTableau.headerRowCount+ ' headerRow'); // conte le nombre de ligne d'en-tête
$.writeln ('AP :' +monTableau.footerRowCount + ' footerRow'); // conte le nombre de ligne de pied de page
First pass:
Première passe :
AV : 2 headerRow
AV : 2 footerRow
AP : 0 headerRow
AP : 0 footerRow
Thank you all
Merci à vous tous
-
6. Re: [JS] Table RowTypes.BODY_ROW
Jump_Over Jan 27, 2014 1:47 PM (in response to Marc Autret)Hi,
I was wondering about "everyItem() way" but test failed indeed...
Looks like it works step by step, row by row...
Jarek
-
7. Re: [JS] Table RowTypes.BODY_ROW
Marc Autret Jan 27, 2014 6:06 PM (in response to Jump_Over)Hi Jarek,
I finally understood (I think) why the plural command fails for header rows while it works like a charm for footer rows.
1. Indeed, when myTable.rows.everyItem().properties=… is executed, rows are processed by increasing index. But row[ i ] cannot be set to BODY_ROW as long as row[ i+1 ] is a HEADER_ROW. Therefore row[0], row[1], ..., row[headerRowCount-2] are not converted into BODY_ROW and the command continues its course on the remaining rows. (As you know, the syntax everyItem().properties=obj bypasses unproper assignments.) By contrast, the last rows are properly set to BODY_ROW, as there is no problem in converting footer rows into body rows by increasing index. This is exactly what Harbs and Peter remarked above.
2. Now, an interesting question: can we control the order by which items are processed through a plural specifier? As to everyItem(), I don't think so. But itemByRange() seems to open up possibilities…
Ideally one would like to do:
rows.itemByRange( headerRowCount-1, 0 ).properties = obj; // descending indexes for header rows
and
rows.itemByRange( -footerRowCount, -1 ).properties = obj; // ascending indexes for footer rows
The footer part works fine (as expected), but the header stuff still leads to the original issue—only the last header row is converted.
3. However, the specifier is properly parsed "…row[N] to …row[0]" as revealed by toSpecifier(). In my view the rows are passed in the desired order, BUT something else overrides this option…
4. It's time to remember that Row and Column objects are just 'wigs' over actual Cells. Behind the scenes, our range of rows still needs to be resolved as a pure range of cells. During this process I suspect that the subsystem reorders the implied targets in an optimal way. So "…row[N] to …row[0]" silently becomes "…cell[0] to …cell[idx]" and our efforts in vain! Well. This reasoning has led me to try a more explicit approach: instead of using myTable.rows.itemByRange(N,0)… let's directly provide the descending cell range: myTable.cells.itemByRange(idx,0).
And you know what? …
// var myTable = ... var o = {rowType: +RowTypes.BODY_ROW}, x; if( x=myTable.headerRowCount ) { x = myTable.rows[x-1].cells[-1].id; myTable.cells.itemByRange(x,0).properties = o; } if( x=myTable.footerRowCount ) myTable.rows.itemByRange(-x,-1).properties = o;Is this snippet significantly more effective than existing solutions based on array loops? That's not my point. Just sharing my theory on ordering commands on cell ranges.
@+
Marc
-
8. Re: [JS] Table RowTypes.BODY_ROW
Jump_Over Jan 28, 2014 12:43 AM (in response to Marc Autret)Yo Marc,
If I only would have your flashlight instead of my candle walking through the InDesign maze...
Jarek
-
9. Re: [JS] Table RowTypes.BODY_ROW
pkahrel Jan 28, 2014 2:55 AM (in response to Marc Autret)Nice one, Marc. Thanks.
Peter
-
10. Re: [JS] Table RowTypes.BODY_ROW
Philippe Ruelle Jan 28, 2014 11:19 AM (in response to Marc Autret)Super analysis thank you Marc! I agree with the remark Jarek.



