Delete row if json response is undefined

You must Login before you can answer or comment on any questions.

hi, I would like to delete a specific row the object is undefined, how can I do that?

if (json.response.posts[i].caption === '' || json.response.posts[i].caption === undefined) {
delete(row); ?
remove(row); ?
}

2 Answers

Hi julien, Referring your sample code, and try this to remove

if (json.response.posts[i].caption === '  ' || json.response.posts[i].caption === undefined) {
delete json.response.posts[i].caption
}
this code will remove the caption object if it is blank or undefined

or you can also try this code if caption if not an object or delete function does not work as per your need.

if (json.response.posts[i].caption === '  ' || json.response.posts[i].caption === undefined) {
json.response.posts.splice(i,1);
}
After adding rows to table you should call tableView.deleteRow(row index to be deleted), above two solutions are for before adding data to table.

— answered 8 months ago by Ashish Nigam
answer permalink
4 Comments
  • when doing this : tableView.deleteRow(row index to be deleted), how can i detect the row where caption is deleted?

    — commented 8 months ago by Julien Gattegno

  • tableView has an event delete which give you the row number and id, even every detail of row.

    — commented 8 months ago by Ashish Nigam

  • cant make it to work...

    — commented 8 months ago by Julien Gattegno

  • Show 1 more comment

Your Answer

Think you can help? Login to answer this question!