Skip navigation
Axel44FR
Currently Being Moderated

How delete row in table by java script ?

May 11, 2012 5:45 AM

hello,

 

i have a big table of thousands lines and i have to delete the blank row

 

How do i this ?

 

thanks

 

Axel

 
Replies
  • Currently Being Moderated
    May 11, 2012 6:11 AM   in reply to Axel44FR

    You need to select a Table, and then select a row in the table, and apply remove();

     

     

    //myTable --> [table object]
    n=0 // index of rows in the table
    myTable.rows[n].remove();
    
    

     

     

    You can try this example . Insert the mouse in the table cell or select a cell or row and then click on the script . this script remove the first row of a table if the selection is inside a table.

     

    selection = app.selection[0].parent;
    
    
    if(selection.toString() == "[object Table]")
    selection.rows[0].remove();
    else if(selection.parent.toString() == "[object Table]")
    selection.parent.rows[0].remove();
    
    
     
    |
    Mark as:
  • Currently Being Moderated
    Jul 27, 2012 3:09 AM   in reply to Axel44FR

    Hi Axel,

     

    Please try the below JS code.

     

    First you have to select the entire table and then run the script. This script will delte the row if the the words count is 0.

    Note: If, your table have any space in the any cells this script will not delete.

     

     

     

    var myTable = app.selection[0].parent.tables[0];

    for(i=myTable.rows.length-1; i>=0; i--){

        if(myTable.rows[i].cells.everyItem().words.length==0){

            //If you need select the row use the below line

            myTable.rows[i].select();

            //If you need to delete the blank row use the below line.

            myTable.rows[i].remove();

            }

        }

     

    thx

    csm_phil

     
    |
    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