|
Delete Clientside datarow -- o0JoeCool0o --
I came accross an old post about it but there was no answer for how to delete a datarow from a datable. right now I am manually using a loop to create a new datatable and then I jsut omit the one i dont want, seems like a lot of code just to delete a row, is there anything in the newer versions now that support datarow deletion client side? |
|
-- AdamRogas --
I have always just set the row to null, but that does have the problem of making length useless. the other option is you could abstract the entire thing out and build a pseudo collection object that uses the array you currently have as the backing object. On 7/10/06, o0JoeCool0o <o0JoeCool0o> wrote: I came accross an old post about it but there was no answer for how to delete a datarow from a datable. right now I am manually using a loop to create a new datatable and then I jsut omit the one i dont want, seems like a lot of code just to delete a row, is there anything in the newer versions now that support datarow deletion client side? > |
|
-- o0JoeCool0o --
yeah as I said thats what I am doing now, manually extracting everything out and creating a new datatable I just figured there would be a delete method by now to delete rows. |
|
-- INeedADip --
I do something like: var rowToDelete = 12; var x,j; for(x=rowToDelete,j=DataTable.Rows.length-1;x<j;x++) DataTable.Rows DataTable.Rows.length = DataTable.Rows.length -1; |
|
-- o0JoeCool0o --
that is an interesting approach, shifting everything down and removing the last entry I like it. maybe Micheal can add it into his wrapper some time as the delete method. |
|
-- o0JoeCool0o --
hmm for soem reason when I try your code it ends up setting the length property to "NaN" whatever that means.... var rowToDelete = 12; var x,j; for(x=rowToDelete,j=newItems.Rows.length-1;x<j;x++) { newItems.Rows ; } newItems.length = newItems.length - 1; alert(newItems.length); the alert at the bottom pops up "NaN" |
|
-- o0JoeCool0o --
oops perhaps newItems.Rows.length instead of newItems.length.... lolol |