Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Table header problem

Avatar

Level 9

In the form linked below, is there a way to have only one table header instead of a header above every single row dynamically generated? I set the binding of the header row to a mamimum of one (1) but it did not seem to have any effect. I want the header to dissappear if the user deletes all of the rows (deletes with the last visible row).

https://acrobat.com/#d=Mmpq-vPoGUdJumXEcaG6Sg

Thanks for any help you can provide with this.

-Don

1 Accepted Solution

Avatar

Correct answer by
Level 10

Place the following code in the click event of the "DeleteActionRow" button.

var nResponse = xfa.host.messageBox("You are about to delete this Action Item row. \n\nDo you want to continue?", "Deleting a row", 1, 2);
if (nResponse == 4) {

var oActionSubform = MeetingMinutes.LogoControls.resolveNode("ActionSubform[" + this.parent.parent.parent.index + "]");
var intCount = oActionSubform.Table1.Row2.instanceManager.count;
 
oActionSubform.Table1.Row2.instanceManager.removeInstance(this.parent.index);


    if(intCount==1){   
    oActionSubform.Table1.HeaderA.presence = "hidden";
    }
   
    if (xfa.host.version < 8) {
     xfa.form.recalculate(1);
    }   
}

Place the following code in the Initialize event of the "DeleteActionRow" button".

var oActionSubform = MeetingMinutes.LogoControls.resolveNode("ActionSubform[" + this.parent.parent.parent.index + "]");

if(this.parent.instanceManager.count>0){

      oActionSubform.TopicGroupA.Table1.HeaderA.presence = "visible";

}

Thanks

Srini

View solution in original post

6 Replies

Avatar

Level 10

Few things to do to achieve what you wanted to do.

1) For "ActionSubform", in the binding tab, uncheck the "Repeating subform for each data item"

2) For "Table1", in the binding tab, uncheck the "Repeating subform for each data item"

3) For "Row2", in the binding tab, check the "Repeating subform for each data item"

    Do not check the min count.

4) In the click event of "AddActionRowButton1" button write the following code.

    

     this.resolveNode('ActionSubform.Table1._Row2').addInstance(1);

     MeetingMinutes.LogoControls.TopicGroupA.ActionSubform.Table1.HeaderA.presence = "visible";

      

     if (xfa.host.version < 8) {

      xfa.form.recalculate(1);

     }

5) For "HeaderA" object propeties,  change the Row type to Body Row instead of Header Row.

     In the Object properties, set the Presence to Hidden.

6) In the click event of "DeleteActionItem" button write the following code.

      

     var intIndex = this.parent.index;
     this.resolveNode('ActionSubform.Table1._Row2').removeInstance(intIndex);

     if(intIndex == 0){
           MeetingMinutes.LogoControls.TopicGroupA.ActionSubform.Table1.HeaderA.presence = "hidden";
     }

     if (xfa.host.version < 8) {
      xfa.form.recalculate(1);
     }

7) In the initialize event of "DeleteActionItem" button write the following code.

    

     if(this.parent.instanceManager.count>0){

      MeetingMinutes.LogoControls.TopicGroupA.ActionSubform.Table1.HeaderA.presence = "visible";

     }

Hope this helps..

Let me know if you still have issues..

Thanks

Srini

Avatar

Level 9

Srini,

I appreciate your help with this.

  • I wanted to warn the user before the action item row was deleted so I added a messagebox before your code.
  • ActionSubform - I kept the binding tab checked because otherwise the "Add Topic Button" stops working.

The problems currently are:

  1. Body row "HeaderA" does not go away when the last visible action item row is deleted.
  2. When I click the, "Add a Topic" button and then try to add an action row to that new topic section, "HeaderA" does not appear above the first action item row.
  3. I am unable to delete the new topic sections for some reason. That "DeleteTopic" button is not working.

Here's the revised form if you would please take a look:

https://acrobat.com/#d=QkwyNjDIFBB0LSgZkEMEJQ

Thank you,

~Don

Avatar

Level 10

Here are the answers for your issues..

1) in the click event of the DeleteActionItem button place the following code.

   

var nResponse = xfa.host.messageBox("You are about to delete this Action Item row. \n\nDo you want to continue?", "Deleting a row", 1, 2);
if (nResponse == 4) {

var oActionSubform = MeetingMinutes.LogoControls.resolveNode("ActionSubform[" + this.parent.parent.index + "]");

var intIndex = this.parent.index;
    oActionSubform.Table1.Row2.instanceManager.removeInstance(intIndex);

    if(intIndex == 0){
     xfa.host.messageBox("1");
   oActionSubform.Table1.HeaderA.presence = "invisible";    
     xfa.host.messageBox("1");
    }
   
    if (xfa.host.version < 8) {
     xfa.form.recalculate(1);
    }
}

2) In the Click event of the AddActionRowButton1 button, place the following code.

   

var oActionSubform = MeetingMinutes.LogoControls.resolveNode("ActionSubform[" + this.parent.parent.index + "]");

  this.resolveNode('ActionSubform.Table1._Row2').addInstance(1);
     oActionSubform.Table1.HeaderA.presence = "visible";
      
     if (xfa.host.version < 8) {
      xfa.form.recalculate(1);
     }

3) In the DeleteTopic button, place the following code.

  

var nResponse = xfa.host.messageBox("You are about to delete this Action Item row. \n\nDo you want to continue?", "Deleting a row", 1, 2);

if (nResponse == 4)
this.resolveNode('LogoControls._ActionSubform').removeInstance(this.parent.parent.index);

if (xfa.host.version < 8) {
xfa.form.recalculate(1);
}

Thanks

Srini

Avatar

Level 9

Sirini,

I'm sorry - I don't know what i have wrong.

  1. I receive an error when i delete the last visible action item row. The error only has "1" on it. If I press okay two times, the body row "HeaderA" does go awau but leaves a space where it was.
  2. The "delete action row" buttons only work on the first instance, not the second, third, etc...

I have uplaoded the revised form.

https://acrobat.com/#d=tVb*Kh2yJ89PMB32gjlCHQ

Thank you,

~Don

Avatar

Correct answer by
Level 10

Place the following code in the click event of the "DeleteActionRow" button.

var nResponse = xfa.host.messageBox("You are about to delete this Action Item row. \n\nDo you want to continue?", "Deleting a row", 1, 2);
if (nResponse == 4) {

var oActionSubform = MeetingMinutes.LogoControls.resolveNode("ActionSubform[" + this.parent.parent.parent.index + "]");
var intCount = oActionSubform.Table1.Row2.instanceManager.count;
 
oActionSubform.Table1.Row2.instanceManager.removeInstance(this.parent.index);


    if(intCount==1){   
    oActionSubform.Table1.HeaderA.presence = "hidden";
    }
   
    if (xfa.host.version < 8) {
     xfa.form.recalculate(1);
    }   
}

Place the following code in the Initialize event of the "DeleteActionRow" button".

var oActionSubform = MeetingMinutes.LogoControls.resolveNode("ActionSubform[" + this.parent.parent.parent.index + "]");

if(this.parent.instanceManager.count>0){

      oActionSubform.TopicGroupA.Table1.HeaderA.presence = "visible";

}

Thanks

Srini

Avatar

Level 9

Srini,

Thank you so much for taking the time to disgnose what I scripted wrong. I am very grateful to you for all your help and sharing your expertise. You are extremely talented and I hope to one day learn all this code you have so willingly shared.

Thanks so very much!

~Don