Forum
17:13
30/05/2014
Hello guys, im starting in javascript world and need your help
i'm using jqgrid to get data from my server, this data now in my grid and usind sortablerows to move the rows, the problem is that i need save new order in the DB.
i need save the info using get submit.
Ex. urlService +"guardarCambios?callback=?"
urlService: url where is my webservice
guardarCambios?callback=? here call my method to send data, my code is this.
jQuery("#list").jqGrid({
url: urlService+"llamarDatos?callback=?",
postData:{Programa:programa},
datatype: "json",
mtype: "GET",
colNames: ['Orden','Nombre','Posición','Tipo' ,'','<input name="guardar" type="image" src="Resources/bt_mas.png" onclick=nuevapromocion(); width=20 height=20/>'],
colModel: [ { name:'orden', index: 'orden',sortable:false, width: 30 ,resizable:true, hidden:false},
{ name:'nombre', index: 'nombre',sortable:false, width: 100 ,resizable:true},
{ name:'posicion', index: 'posicion',sortable:false, width: 100 ,resizable:true},
{ name:'tipo', index: 'tipo',sortable:false, width: 70 ,resizable:false},
{ name:'Action',width: 30, sortable: false, classes: 'action', align: 'center',resizable:false},
{ name:'Action2',width:30,align:'center',resizable:false,sortable:false,},
],
rowNum: 10,
loadonce:true,
pager: jQuery('#pager'),
height: 'auto',
width: 525,
viewrecords: false,
sortorder: "desc",
gridComplete:function(){
var pIDs = jQuery("#list").jqGrid('getDataIDs');
for(var i=0; i<pIDs.length; i++){
var option='';
var cl = pIDs[i];
fila = jQuery("#list").jqGrid('getRowData', pIDs[i]);
position = fila.posicion;
orden = fila.orden;
btnDelete = "<input style='height:22px;' type='image' src=\"Resources/btn_borrar.png\" onclick=eliminar("+cl+"); float=\"center\"/>";
btnEdit = "<input style='height:22px;' type='image' src=\"Resources/btn_editar.png\" onclick=\"editar("+cl+")\" float=\"center\"/>";
if(position=="Arriba Izquierda" || orden=='1'){
jQuery("#list").jqGrid('setRowData',pIDs[i],{Action:btnEdit});
}
else{
jQuery("#list").jqGrid('setRowData',pIDs[i],{Action:btnEdit});
jQuery("#list").jqGrid('setRowData',pIDs[i],{Action2:btnDelete});
}
}
}
});
$("#list").jqGrid('sortableRows',
{
update : function(e,ui) {
$.getJSON(urlService+"guardarCambios?callback=?",{id:ui.item[0].id,orden:ui.item[0].rowIndex,Programa:programa},
function(data){
jQuery("#list").setGridParam({sortorder: "asc"}).jqGrid("sortGrid", "order_index", true);
jQuery("#list").trigger("reloadGrid");
});
alert("item with id=" + ui.item[0].id + " is droped");
}});
});
i need this Demo
17:11
Moderators
30/10/2007
Hello,
In the update event you define you can get the new order of the id.
To get the new ids you can use getDataIDs grid method.
Kind Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
12:08
Moderators
30/10/2007
Hello,
As far as I understand you will need to use this in the update event in sortable rows, so that you get the new order and send it to the server - as far as I understand the requierment.
Kind Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
42 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66