jqgrid ajax,jquery - jqGrid. Async ajax calls - Stack Overflow

first of all, thanks for your time.

I'm trying to use jqGrid to make an editable grid. I'd like the user edit lines, jqGrid send changes and WITHOUT waiting response from server, user continue editing lines. If server response is OK, do nothing, and if there is some error I'd show some kind of error log (but this doesn´t worry me).

This code works:

var ultimaFila = 0; // globally available

var saveActRow = function(){

jQuery('#gridLineas').jqGrid('saveRow', ultimaFila,

function(xhr) {

var response = eval('(' + xhr.responseText + ')');

if(response.respuesta == "ok"){

return true;

} else{

return false;

}

}

, 'ActualizarLineaAlbaran.action'

);

};

var addActRow = function(e) {

var lastRowInd = jQuery("#gridLineas").jqGrid("getGridParam","reccount");

if (ultimaFila == lastRowInd){ // ¿es última línea?

jQuery("#gridLineas").jqGrid('addRow',{

rowID : parseInt(ultimaFila) + 1,

initdata : {'numLinea':parseInt(ultimaFila) + 1},

position :"last",

useDefValues : false,

useFormatter : false,

addRowParams : {extraparam:{}}

});

}

};

jQuery(document).ready(function(){

$("#gridLineas").jqGrid({

jsonReader : {root:"albaLineas", cell: "", repeatitems: false},

url:'albaLineas.action',

//ajaxGridOptions: { async: false },

loadui: 'disable',

datatype: 'json',

mtype: 'POST',

colNames:['codIndiceAlb', 'numLinea', 'Código', 'CSP', 'cantidad'],

colModel :[

{name:'codIndiceAlb', index:'codIndiceAlb', hidden: true, width:50, editable: false, sortable:false, align: "center"},

{name:'numLinea', index:'numLinea', hidden: false, width:50, editable: false, sortable:false, align: "right"},

{name:'codigoArticulo', index:'codigoArticulo', width:50, editable: true, sortable:false, align: "right"},

{name:'articuloCSP', index:'articuloCSP', width:50, editable: true, sortable:false, align: "right"},

{name:'cantidad', index:'cantidad', width:60, editable: true, sortable:false, align: "right",

editoptions: { dataEvents: [

{ type: 'keydown', fn: function(e) {

var key = e.charCode || e.keyCode;

if (key == 13){

saveActRow();

addActRow();

}}}]}

},

],

rowNum:100,

sortname: 'numLinea',

sortorder: 'desc',

gridview: true,

caption: 'líneas',

height: 350,

loadtext :'cargando líneas...',

editurl: 'ActualizarLineaAlbaran.action',

onSelectRow: function(id) {

if (id && id !== ultimaFila) {

jQuery('#gridLineas').jqGrid('restoreRow',ultimaFila);

ultimaFila = id;

/*jQuery("#grid_id").jqGrid('editRow',rowid, keys, oneditfunc,

succesfunc, url, extraparam, aftersavefunc,errorfunc, afterrestorefunc);*/

jQuery('#gridLineas').jqGrid('editRow', id, false, null,

function(xhr) {

/* SUCCESFUNC*/

var response = eval('(' + xhr.responseText + ')');

if(response.respuesta == "ok"){

return true;

} else{

return false;

}

}

, 'ActualizarLineaAlbaran.action'

);

}

}

});

but user can't continue editing until server response. I thought Ajax tech was usefully for this, but I'm an absolutely newbie in Ajax and jGrid.

I tried Synchronous Calls with jqGrid? answer, but no result for me.

So, is there anyway to don't "wait" server answer?

Any help is appreciated.

Thank you,

Jon

************* EDITED - RESPONSE TO OLEG ANSWER ***********

thanks again Oleg! the ajaxRowOptions: { async: true } works perfect, but (there is always a but ;-)) users stills see the gray grid. I suspect there is something to do with

ui.jqgrid.css line .ui-jqgrid .jqgrid-overlay

because if I delete this line overlay is out, but I have unexpected results (grid is allways gray). With Firebug I see that

line is the one witch is showing the overlay, but do someone know how to overwrite this particular line? Witch is the script code that change de style from display to block?

Thanks everyone! and have a good day!

Jon

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值