5 Replies Latest reply: Jun 29, 2009 8:29 PM by rajdudi RSS

    Remove Instance from a Form at run time

    rajdudi

      form.GIF

      I want to remove the rows of a table in a form at runtime.

       

      I have created the table by customising a button and writting javascript.

       

      now i want to delete some rows of the table by another button,.

       

      For example i added 4 rows in above form and i want to delete 2 rows (1st and 3rd)

      when i click remove button it will delete only 1st row.

      the java script of remove button is like this:

       

       

       

      for(i=xfa.form.plan.planDocument.plan1.task.instanceManager.max;i>=1;i--)

      {

       

       

       

       

      if(i>xfa.form.plan.planDocument.plan1.task.instanceManager.min)

      {

       

       

       

       

      if(plan.planDocument.Header.plan1.task.Table5.Row1.rowdelete.rawValue==1)

      {

       

      xfa.form.plan.planDocument.Header.plan1.task.instanceManager.removeInstance(0);

      }

      }

       

       

       

       

      }

       

       

       

       

      This deletes only the first row that is selected

      How can i do this.

       

      The instanceManager.removeinstance() method delete only the first row of the all selected rows..

        • 1. Re: Remove Instance from a Form at run time
          rajdudi Community Member

          Replyyyyyyyyyyyyyy?????/

          • 2. Re: Remove Instance from a Form at run time
            madhu_livecycle Community Member

            Hi rajdudi,

             

            replace ur line

            xfa.form.plan.planDocument.Header.plan1.task.instanceManager.removeInstance(0);

            with

            xfa.resolveNode("form.plan.planDocument.Header.plan1.taskTable5.Row1.instanceManager.remov eInstance("

            +i+")"); have a try.

             

            by passing i to removeInstance, it knows the index of the row to delete

             

            Thanks,

            Madhu.

            • 3. Re: Remove Instance from a Form at run time
              rajdudi Community Member

              Hi Madhu,

               

              Thanks for the reply.

               

              But the changes you advised me to make in the script are not working to give the required result.

               

               

              if(plan.planDocument.Header.plan1.task.Table5.Row1.rowdelete.rawValue==1)

              }

              {

              xfa.resolveNode("form.plan.planDocument.Header.plan1.taskTable5.Row1.instanceMan ager.removeInstance("

              +i+")");

               

              In this script the if statement always checks the first row of the table and then Removeinstance removes the ith row of the table irrespective of the status of Delete check of that row.Whethre it was checked or not.

               

              For example 1st row is checked and i=2 then if then this script will remove the 2nd row.

               

              I want the script deletes all the checked rows only

               

               

               

               

              • 4. Re: Remove Instance from a Form at run time
                madhu_livecycle Community Member

                Hi rajdudi,

                 

                please find the attached sample form.

                 

                i have written a script for Delete button in click event which calls a function

                removenull.removecheckedrows()

                 

                code in click event of button

                 

                 

                 

                 

                 

                 

                var

                 

                tlength = xfa.resolveNodes("body.Table1.Row1[*]").length;

                for

                 

                ( var j=1; j<tlength; j++)

                {

                 

                 

                if(!removenull.removecheckedrows())

                 

                 

                break;

                 

                 

                else

                 

                 

                continue;

                }

                 

                 

                and written a function

                 

                 

                // Function to remove the Checked rows from Table1

                function

                 

                 

                removecheckedrows()

                {

                 

                 

                var tlength =

                xfa.resolveNodes("body.Table1.Row1[*]").length;

                 

                 

                for ( var i=0; i<tlength; i++

                )

                {

                 

                 

                if(xfa.resolveNode("body.Table1.Row1["+i+"].CheckBox1").rawValue ==

                1 )

                {

                body.Table1.Row1.instanceManager.removeInstance(i);

                 

                 

                return true

                ;

                }

                }

                }

                 

                // end function

                 

                which will remove the selected rows.

                try to implement this in your form

                 

                if u r unable to download attached form give ur mailid i will forward the same.

                 

                 

                 

                 

                Thanks,

                Madhu.

                 

                 

                 

                 

                 

                • 5. Re: Remove Instance from a Form at run time
                  rajdudi Community Member

                  Hi Madhu,

                   

                  I am not able to download the attachment in your reply.

                  Please send me that from at rajdudi@gmail.com

                   

                  Thanks,

                  Raj Dudi

                  9764006704 | Pune