Skip navigation
rajdudi
Currently Being Moderated

Remove Instance from a Form at run time

Jun 26, 2009 2:43 AM

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.removeIns tance(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..

 
Replies
  • Currently Being Moderated
    Jun 26, 2009 6:23 AM   in reply to rajdudi

    Hi rajdudi,

     

    replace ur line

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

    with

    xfa.resolveNode("form.plan.planDocument.Header.plan1.taskTable5.Row1.i nstanceManager.removeInstance("

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

     

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

     

    Thanks,

    Madhu.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 29, 2009 5:56 AM   in reply to rajdudi

    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.

     

     

     

     

     

    Attachments:
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points