Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Save changes in DB using Sortablerows
30/05/2014
17:13
Avatar
Bourne
New Member
Members
Forum Posts: 2
Member Since:
30/05/2014
sp_UserOfflineSmall Offline

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.

$(function(){

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

02/06/2014
17:11
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

02/06/2014
19:36
Avatar
Bourne
New Member
Members
Forum Posts: 2
Member Since:
30/05/2014
sp_UserOfflineSmall Offline

thanks for your answer Tony

i need use getDataIDs before or after Update?

i'm newbie in javascript :(

06/06/2014
12:08
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
23 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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information