Expand my Community achievements bar.

SOLVED

Scripting for specific cell in a table

Avatar

Level 1

Hi All,

   I am displaying a table which contains subtotals and grand-total and this table is coming as an XML file from a Java program directly.

The exact cells in a row which contains subtotal text and grand total text have to be enclosed with a border as shown below:-

1655625_pastedImage_1.png

I was able to achieve it using this code

if (this.rawValue == "Sub-Total:" || this.rawValue == "Grand Total:") {

   this.font.weight = "bold";

   this.border.getElement("edge",0).presence = "visible";

   this.border.getElement("edge",1).presence = "invisible";

   this.border.getElement("edge",2).presence = "visible";

   this.border.getElement("edge",3).presence = "invisible";

}

The issue is the subsequent cell which contains the subtotal and grand total value also has to be enclosed with a border similarly. But I am not able to achieve this functionality. Kindly suggest a solution.

1 Accepted Solution

Avatar

Correct answer by
Level 10

You can set the borders of the surrounding row instead of the cells.

var oThis = this,

    oParent = oThis.parent;

if (oThis.rawValue.match(/^(Sub-Total:|Grand Total:)$/g)) {

  oThis.font.weight = "bold";

  oParent.border.getElement("edge",0).presence = "visible";

  oParent.border.getElement("edge",1).presence = "invisible";

  oParent.border.getElement("edge",2).presence = "visible";

  oParent.border.getElement("edge",3).presence = "invisible";

}

If you only want set the borders of specific cells on each row you can do this the following way:

var oThis = this,

    oParent = oThis.parent;

if (oThis.rawValue.match(/^(Sub-Total:|Grand Total:)$/g)) {

   oThis.font.weight = "bold";

   // Modify cell named "Cell1"

   oParent.Cell1.border.getElement("edge",0).presence = "visible";

   oParent.Cell1.border.getElement("edge",1).presence = "invisible";

   oParent.Cell1.border.getElement("edge",2).presence = "visible";

   oParent.Cell1.border.getElement("edge",3).presence = "invisible";

   // Modify cell named "Cell3"

   oParent.Cell3.border.getElement("edge",0).presence = "visible";

   oParent.Cell3.border.getElement("edge",1).presence = "invisible";

   oParent.Cell3.border.getElement("edge",2).presence = "visible";

   oParent.Cell3.border.getElement("edge",3).presence = "invisible";

}

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

You can set the borders of the surrounding row instead of the cells.

var oThis = this,

    oParent = oThis.parent;

if (oThis.rawValue.match(/^(Sub-Total:|Grand Total:)$/g)) {

  oThis.font.weight = "bold";

  oParent.border.getElement("edge",0).presence = "visible";

  oParent.border.getElement("edge",1).presence = "invisible";

  oParent.border.getElement("edge",2).presence = "visible";

  oParent.border.getElement("edge",3).presence = "invisible";

}

If you only want set the borders of specific cells on each row you can do this the following way:

var oThis = this,

    oParent = oThis.parent;

if (oThis.rawValue.match(/^(Sub-Total:|Grand Total:)$/g)) {

   oThis.font.weight = "bold";

   // Modify cell named "Cell1"

   oParent.Cell1.border.getElement("edge",0).presence = "visible";

   oParent.Cell1.border.getElement("edge",1).presence = "invisible";

   oParent.Cell1.border.getElement("edge",2).presence = "visible";

   oParent.Cell1.border.getElement("edge",3).presence = "invisible";

   // Modify cell named "Cell3"

   oParent.Cell3.border.getElement("edge",0).presence = "visible";

   oParent.Cell3.border.getElement("edge",1).presence = "invisible";

   oParent.Cell3.border.getElement("edge",2).presence = "visible";

   oParent.Cell3.border.getElement("edge",3).presence = "invisible";

}