我花了两天时间尝试使用 json 和 struts2 添加删除和编辑链接到 jqgrid 但徒劳无功。
<script type="text/javascript">
function deleteLinkFormatter(cellval, options, rowObject, icon, link_class, link_action) {
return "<a href='deleteEleve?eleveId="+cellval+"' onClick='javascript: return delete_eleve()'><font class='hyperlink'><u>Delete</u></font></a>";
}
function delete_eleve() {
var agree=confirm("Are you sure you want to Delete?");
if (agree){
return true;
}
else{
return false;
}
}
</script>
我真的花了太多时间来解决这个问题,如果有人可以帮助我将不胜感激。我已经看到了这个链接http://www.trirand.com/blog/jqgrid/jqgrid.html和这个http://struts.jgeppert.com/struts2-jquery-showcase/index.action但没有任何问题。:s
<s:url id="remoteurl" value="/eleve/eleveTable.action"/>
<s:url id="deleteurl" action="deleteEleve" />
<sjg:grid id="gridtable"
caption="Editer Eleves"
dataType="json"
width="755"
href="%{remoteurl}"
pager="true"
gridModel="gridModel"
rowList="5,10,15,20"
rowNum="5"
rownumbers="true"
multiselect="true"
navigator="true"
navigatorView="false"
navigatorDelete="false"
navigatorAdd="false"
navigatorRefresh="false"
navigatorSearch="false"
navigatorEditOptions="{width:600,height:400,reloadAfterSubmit:false}"
navigatorEdit="true"
editurl="%{editurl}"
>
<sjg:gridColumn name="eleveId" title="Eleve Id" formatter="integer" sortable="false"/>
<sjg:gridColumn name="eleveNom" index="eleveNom" title="Eleve Nom" editable="true" edittype="text" sortable="true"/>
<sjg:gridColumn name="elevePrenom" index="elevePrenom" title="Eleve Prenom" editable="true" edittype="text" sortable="false"/>
<sjg:gridColumn name="eleveCne" index="eleveCne" title="Eleve Cne" editable="true" edittype="text" sortable="false"/>
<sjg:gridColumn name="eleveAdresse" index="eleveAdresse" title="Eleve Adresse" editable="true" edittype="text" sortable="false"/>
<sjg:gridColumn name="eleveDatenaissance" index="eleveDatenaissance" title="Datenaissance" editable="true" edittype="date" sortable="false"/>
<sjg:gridColumn name="anneEnregistrement" index="anneEnregistrement" title="Anne Enregistrement" editable="true" edittype="text" sortable="false"/>
<sjg:gridColumn name="membreClub" index="membreClub" title="Membre Club" editable="true" edittype="text" sortable="false"/>
<sjg:gridColumn name="id_classe" index="id_classe" title="classe" editable="true" edittype="text" sortable="false"/>
<sjg:gridColumn name="eleveId" index="EleveId" title="Delete Eleve"
sortable="true" formatter="deleteLinkFormatter" />
</sjg:grid>