Home › Forums › Guriddo jqGrid JS › Help › Custom Form with Jqgrid
Hi,
I want to do something, but not sure if it is possible, and how to do it…
1/
I have a grid, and i want when i select it and press button, to open a modal window, showing some informations of the grid + having new jqgrid with info into it.
exemple:
Lastname |
Hello 😉
I done this :
“
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 ,gridComplete: function(){<br /><br /><br />var re = ''<br />var ad = ''<br />var du = ''<br />var ed = ''<br />var de = ''<br /><br />var ids = jQuery("#service_table").jqGrid("getDataIDs");<br />for(var i=0;i < ids.length;i++)<br />{<br />var cl = ids<i>;<br /><br /><br />re = "<div class="'ui-pg-div'"><span class="'ui-icon" title="'Consulter'"></span></div>";<br />ad = "<div class="'ui-pg-div'"><span class="'ui-icon" title="'Ajouter'"></span></div>";<br />du = "<div class="'ui-pg-div'"><span class="'ui-icon" title="'Dupliquer'"></span></div>";<br />ed = "<div class="'ui-pg-div'"><span class="'ui-icon" title="'Modifier'"></span></div>";<br />de = "<div class="'ui-pg-div'"><span class="'ui-icon" title="'Supprimer'"></span></div>";<br />jQuery("#service_table").jqGrid("setRowData",cl,{grid_actions:re + ad + du + ed + de});<br />}<br /><br />}"<br /><br />"<br /><pre id="line118">function GetserviceForm(method, gridId, formId, rowID){<br />// les donnees pour valider le form : precedes de frm_ car le isValid prend les id des elements du form<br />// on precede de l id du form car IE ne retrouve pas<br />$data = "method="+method+"&id_Prestation="+rowID+"&format=html";<br />var ts = $(gridId + ".ui-jqgrid-btable").get(0);<br />if(ts.grid.hDiv.loading){<br />return;<br />}<br />beginGridRequest(gridId);<br />$.ajax({<br />type: "POST",<br />url:baseUrl + "/index.php/manage_service-getform",<br />async:true,<br />data: $data,<br />success: function(reponse){<br />if(reponse != null && reponse != ""){<br />$(formId).empty();<br />$(formId).append(reponse);<br />/*$(formId).get(0).innerHTML = reponse;*/<br />}else{<br />$(formId).empty();<br />}<br />var labelForm = titleRead;<br /><br /><br />if(method == "edit"){<br />labelForm = titleEdit;<br />}else if(method == "add"){<br />labelForm = titleAdd;<br />}else if(method == "duplicate"){<br />labelForm = titleDuplicate;<br />}<br />endGridRequest(gridId);<br />$(formId)<br />.dialog({bgiframe: true,<br />modal: true,<br />autoOpen: false,<br />height: 250,<br />width: 350,<br />buttons: {Annuler: function() {<br />$("#service_form_div_").dialog("close");<br />},<br />Valider: function() {<br />SubmitserviceForm("#service_table", "#service_form_div_");<br />}}})<br />.dialog({ title: labelForm })<br />.dialog("open");<br /><br /><br />},<br />error: function(reponse, textStatus, errorThrown){<br />endGridRequest(gridId);<br />alert("Execution error");<br />}<br />});<br />}; // Fin CloseForm()<br />function SubmitserviceForm(gridId, formId){<br />$data ="id_Prestation="+$(formId + "id_Prestation").val()+"&libelle="+$(formId + "libelle").val()+"&grid_actions="+$(formId + "grid_actions").val()+"&";<br />var ts = $(gridId + ".ui-jqgrid-btable").get(0);<br />if(ts.grid.hDiv.loading){<br />return;<br />}<br /><br /><br />beginGridRequest(gridId);<br />$.ajax({<br />type: "POST",<br />url:baseUrl + "/index.php/manage_service-check?format=html",<br />async:true,<br />data: $data,<br />success: function(reponse){<br />endGridRequest(gridId);<br />if(reponse != null && reponse != ""){<br />// echec on affiche la reponse, qui et le zend_form avec erreurs<br />$(formId).get(0).innerHTML= $(reponse).get(0).innerHTML;<br />}else{<br />// succes, rechargement du jqgrid et fermeture dialog avec zend_form<br />jQuery(gridId).trigger("reloadGrid");<br />$(formId).dialog("close");<br />}<br />},<br />error: function(reponse, textStatus, errorThrown){<br />endGridRequest(gridId);<br />alert("Execution error");<br />}<br />});<br />}; // Fin SubmitForm()<br /><br /><br />/**<br />* Supprime une ligne du tableau<br />*/<br />function DeleteserviceRow(gridId, rowID){<br />var ts = $(gridId + ".ui-jqgrid-btable").get(0);<br />if(ts.grid.hDiv.loading){<br />return;<br />}<br />jQuery(gridId).setSelection(rowID, false);<br />if (confirm(msgConfirmSupp)) {<br />beginGridRequest(gridId);<br />$.ajax({<br />type: "POST",<br />url: baseUrl + "/index.php/manage_service-delete-"+rowID,<br />dataType:"html",<br />data:"format=html",<br />success: function(reponse){<br />endGridRequest(gridId);<br />if(reponse == ""){<br />jQuery(gridId).delRowData(rowID);<br />}else{<br />alert("Suppression impossible :n" + reponse);<br />}<br />},<br />error: function(reponse, textStatus, errorThrown){<br />endGridRequest(gridId);<br />alert("Execution error");<br />}<br />});<br />} else {<br />jQuery(gridId).resetSelection();<br />} // if<br />}; // fin DeleteRow<br />"<br /><br />It's not perfect (I'll make refactorisation of this code) but it work perfectly :) (I don't like default form edition)<br /><br />Hope this help you
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top