How to delete selected checkBox From the Child table

Hi, People

How to delete the selected checkbox, from the child table.

I have tried the below code to delete the selected row but while saving the button it’s deleting the below unchecked row. How to solve this?

		$.each(frm.doc.table_2, function(index, source_row){
			if(source_row.check_6 == true){
				frm.fields_dict['table_2'].grid.grid_rows[source_row.check_6].remove();
				frm.refresh_field("table_2")
			}

		})

Thank you.

Hi, Thank you all I have find the solution.

		$.each(frm.doc.table_2, function(index, source_row){
			if(source_row.check_6 == true){
				frm.fields_dict['table_2'].grid.grid_rows[index].remove();
				frm.refresh_field("table_2")
			}

		})

Hello, Guys

The way I have solve the above problem is not deleting the row in the right format. Even the unselected rows getting disappear. Kindly help me out of this.
What is the right way to delete the selected Rows only?

I have attached my code.

		$.each(frm.doc.table_2, function(index, source_row){
			if(source_row.check_6 == true){
				frm.fields_dict['table_2'].grid.grid_rows[index].remove();
				frm.refresh_field("table_2")
			}

		})

Thank you