jqGrid - form editing issues -
in inline editing, before editing made, creates internally array (savedrow
) , fill values of fields being editable, can access values.
i'd know if in form editing has similar this, because need access values of fields before editing completed validation before fields "saved" in database.
someone me?
edited :
i'm posting here part of code (the code of 1 field), , i'm trying validate in both way (inline editing , form editing). inline editing i'm validating using dataevents
, there i'm using savedrow
access data not stored yet. when try edit using form editing because of the use of savedrow, shows me error: savedrow not defined
. in case of field editrules
fits want do, don't know if occurs in of fields.
{ name: 'ac_fd', index: 'ac_fd', width: 50, editable: true, formatter: 'number', editrules: { number:true, required:true, minvalue: 0.1, maxvalue: 1.0 }, formatoptions: { decimalplaces: 1, decimalseparator: '.'}, editoptions: { dataevents: [ { type: 'blur', fn: function(e) { var savedrow = $("#list").getgridparam('savedrow'); console.log($(this).val()); if($(this).val() != savedrow[0]['ac_fd']) { var eid='#' + savedrow[0]['id'] + '_ac_fd'; var val_fd=$(this).val(); var fd_min=0.1; var fd_max=1.0; if( isnan(val_fd) || val_fd > fd_max || val_fd < fd_min) { settimeout(function(){ $(eid).focus().select(); },600); $(eid).qtip({ content: { text: 'fator de demanda deve ser um <b>número</b> entre <b>' + fd_min.tofixed(1) + '</b> e <b>' + fd_max.tofixed(1) + '</b>.', title: { text: 'atenção:', button: true } }, show: { event: false, ready: true, effect: function() { $(this).stop(0, 1).fadein(400); }, delay: 0, }, hide: { event: false, effect: function(api) { $(this).stop(0, 1).fadeout(900).queue(function() { api.destroy(); }); }, }, style: { classes: 'qtip-red qtip-rounded trif_tip_err', tip: { width: 10, height:12 } }, position: { my: 'bottom left', at: 'top center', }, events: { render: function(event, api) { tip_timer.call(api.elements.tooltip, event); } } }); } } } } ] } },
so if dataevents
common , used 3 forms of edit, can type of validation (using qtip , want validation used in inline editing too)?
the reason why jqgrid save editing row in interval savedrow
parameter because jqgrid modify editing row in-place. because of inline editing , cell editing use interval savedrow
parameter. form editing don't modifies original row of grid till editing finished. no savedrow
parameter used form editing.
if form closed or if server response contains error http code new data entered user not saved in grid. simple server side validation typically enough. if want implement additional client side validation can use editrules feature. custom validation typically enough. can validate 1 field of form. if need compare multiple fields of form during validation (if value of 1 field defines valid values of field) 1 uses beforecheckvalues callback additionally.
updated: inside of fn
event handler can test whether called inside of form editing or not. there many ways this. example can test $(e.target).closest(".formgrid").length > 0
. if it's true event inside of form. additionally it's important understand current editing row not changed till successful saving on server. can use time getgridparam
"selrow"
option id of editing row , can use getrowdata
or getcell
data grid before modification started (the same savedrow
).
Comments
Post a Comment