0
我想在表中刪除一行,並使用HREF鏈接刪除數據庫,但是當我點擊鏈接線將不會刪除 我的表:刪除行從表HREF
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
<thead>
<tr>
<th> </th>
<th>Kpi</th>
<th>Criticity</th>
<th>Service</th>
<th>Condition Kpi</th>
<th>Condition 1</th>
<th>Condition 2</th>
<th>Condition 3</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
{% for kpi in KPIs %}
<tr class="gradeU">
<td >{{kpi.getid}}</td>
<td>{{ kpi.kpi }}</td>
<td>{{ kpi.criticity}}</td>
<td>{{ kpi.service }}</td>
<td>{{ kpi.conditionkpi }}</td>
<td>{{ kpi.num1 }}</td>
<td>{{ kpi.num2 }}</td>
<td>{{ kpi.num3 }}</td>
<td><a class="edit" href="">Edit</a></td>
<td value="{{kpi.getid}}"><a href="#" onclick="suppLigne(this.parentNode.parentNode)"> Supprimer </a>
</tr>
{% endfor %}
</tbody>
</table>
ma fonction javascript:
function suppLigne(ligne){
ligne.parentNode.removeChild(ligne);
}
我也試圖與這個功能在我的控制器,但仍然沒有很好的答案
public function supprimerkpiAction()
{
$session =$this->get('request')->getSession() ;
$user_name = $session->get('user_name');
$repository = $this->getDoctrine()->getEntityManager()->getRepository('AdminBlogBundle:Conditionalertes');
$id=$this->getRequest()->query->get('id');
$em = $this->getDoctrine()->getEntityManager();
$uti=$repository->find($id);
$em->remove($uti);
$em->flush();
$KPIs = $repository->findAll();
return $this->render('AdminBlogBundle:GestionKPI:supprimer.html.twig', array('user_name'=>$user_name,'KPIs'=>$KPIs));
}
感謝它的作品:) – user1794019
你能接受答案嗎? –