Forum Discussion

msap's avatar
msap
Frequent Contributor
7 years ago

insert a value to new row in a grid

hi all

 

I am trying to insert new row in a grid using below Java script:

rowcount fronm the grid and insert the values into text boxes and combo boxes.

 

getting an error.

Grid row index 116 is out of bounds .

 

any ideas.

 

Grid1.ClickItem("Edit");
Grid1.ClickItem("New");
Grid2=Grid.grid

RowIndex=Grid2.wRowCount;

  • wRowCount = number of rows.

     

    However, while the number of rows may be 116, the INDEX of the last row is 115.  When setting RowIndex, use the following

     

    RowIndex=Grid2.wRowCount -1;
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    wRowCount = number of rows.

     

    However, while the number of rows may be 116, the INDEX of the last row is 115.  When setting RowIndex, use the following

     

    RowIndex=Grid2.wRowCount -1;
    • msap's avatar
      msap
      Frequent Contributor

      I am trying to edit the same , but it just concatenates.

      any suggestions!

       


      Grid2.Keys ("US123" + "[Tab]" );

       

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        msap wrote:

        I am trying to edit the same , but it just concatenates.

        any suggestions!

         

         

        RowIndex = Grid2.FindRow("Attribute Type", "USA123");
        // Change the row data
        Grid2.ClickCell (RowIndex, "Attribute Type");
        Grid2.Keys ("US123" + "[Tab]" );

         


        All Keys does is simulate keystrokes in the field.  So, basically it's like you click on the cell and start typing...  If you want to actually replace the data in the field, change your code to the following.  Note the CTRL-A call (the carat followed by a) that does a select all for the data field.


        RowIndex = Grid2.FindRow("Attribute Type", "USA123");
        // Change the row data
        Grid2.ClickCell (RowIndex, "Attribute Type");
        Grid2.Keys ("^aUS123[Tab]" );