I need to be able to add multiple rows client side. I have tried to use igtbl_addNew, but it wont add multiple new lines without there being data in each existing lines. Anyone know a way around this?
Rob,
Try this:
function AddBlankGridRows_Click(oButton, oEvent) //this is called via a web image button click....{ var tbAddRows = document.getElementById("ctl00_cphContent_tbRowCnt"); //get text box... var addRowCnt = tbAddRows.value; //a text box with the number of rows you want to add... var aNum ; var grid = igtbl_getGridById("ctl00_cphContent_GRIDNAME"); if (addRowCnt == "") { grid.Rows.addNew(); } else if (addRowCnt != "") { for (aNum = 1; aNum <= addRowCnt; aNum++) { grid.Rows.addNew(); } tbAddRows.value = ""; } }}
var newRow = GrdBspCompanyRowsCollection.addNew(); --- Adding a new blank row to the rows collection
newRow.getCellFromKey('CompanyName').setValue(txtCompanyName.value);
newRow.getCellFromKey('BspPlugInID').setValue($get('<%= this.hfBspPluginID.ClientID %>').value);
This works when there are actual rows in the grid. My problem is if there is an empty grid this will fail.
That is client side code but from what I have tried it does not work. The method keeps returning my an undefined row. So I can't add any rows to my grid through the client side.
That code seems to be server side. In the application I am doing, I want to allow the user to enter several lines of data without posting back to the server until they click a submit button. To complicate matters, they would like to be able to enter a number of lines to add and add them all at one time.
I was hoping that someone would have tried this before me and could tell me how to get it accomplished.
Hi,
U can use the following code.
var j = txtRows.value; for(var i=0; i < j; i++) { row=myGrid.Rows.addNew(); }
Thanks,
Kedar.