type plugin manager jsgrid grilla gridder control javascript jquery ajax datagrid jqgrid

javascript - plugin - Enviar parámetros adicionales a editurl en JQgrid



jquery gridder (3)

Mi problema ahora es tratar de enviar el ID ( editable: false ) de una fila al editar esa fila.

Por ejemplo, tengo una grilla con columnas ID de usuario ( editable: false ), nombre de usuario ( editable: true ), nombre ( editable: true ), apellido ( editable: true ). Al editar la fila, la grilla solo está enviando los parámetros username, firstname y lastname. En el lado del servidor, necesito el userid para saber a qué usuario he aplicado esos nuevos valores.

el editUrl se ve así:

editurl : CONTEXT_PATH+''/ajax/admin/savePart.do?category=1'',

Gracias

Este es el código completo:

$.jgrid.useJSON = true; //http://www.trirand.com/jqgridwiki/doku.php?id=wiki%3Acommon_rules $(document).ready(function() { //alert(CONTEXT_PATH); var lastsel; jQuery("#rowed3").jqGrid( { url : CONTEXT_PATH+''/ajax/getPartesByCategory.do?catid=<s:property value="categoryId" />'', //url : ''/autoWEB/text.html'', datatype: "json", ajaxGridOptions: { contentType: "application/json" }, jsonReader : { root: "rows", page: "page", total: "total", records: "records", repeatitems: false }, headertitles: true, colNames : [ ''ID'', ''Pieza'', ''Disponible''], colModel : [ { name : ''piezaId'', index : ''piezaId'', align : "right", width : 50, editable : false, required : true }, { name : ''descripcion'', index : ''descripcion'', width : 390, editable : true, required : true }, { name : ''disponible'', index : ''disponible'', width : 80, editable : true, edittype : ''select'', editoptions:{value:"0:No;1:Si"}, required : true } ], rowNum : 20, rowList : [ 20, 40, 60, 80 ], pager : ''#prowed3'', sortname : ''piezaId'', postData: {piezaId : lastsel}, mtype:"POST", viewrecords : true, sortorder : "desc", onSelectRow : function(id) { if (id && id !== lastsel) { jQuery(''#rowed3'').jqGrid(''restoreRow'', lastsel); jQuery(''#rowed3'').jqGrid(''editRow'', id, true); lastsel = id; } }, editurl : CONTEXT_PATH+''/ajax/admin/savePieza.do?categoria=<s:property value="categoryId" />'', caption : "Piezas" }); jQuery("#rowed3").jqGrid(''navGrid'', "#prowed3", { edit : false, add : false, del : false }); })


Puedes usar

hidden: true, editable: true, editrules: { edithidden: false }, hidedlg: true

en la definición de la piezaId (ID). El parámetro hidedlg actualmente no es realmente necesario, pero puede ser útil si decides usar otras características de jqGrid.


en su devolución de llamada onSelectRow, puede modificar editUrl para que sea lo que desee, incluido el ingreso de la ID que necesita.

$("#rowed3").jqGrid(''setGridParam'', {editurl:''whatever/url/you/need/with/the/id''});

jqGrid agregará todos los demás parámetros necesarios a ese editurl para usted.


Pasar valores en la cadena GET funcionó para mí.

editurl: ''/ajax/update?line=1'',