有没有办法在添加或编辑行时避免表单关闭.
Jqgrid在我们的应用程序中工作得很好,但是有一点问题,当用户通过表单编辑编辑或创建一行并且用户在表单的模态外单击时,模式关闭并且更改丢失.避免这种行为是否可行?
Jqgrid在我们的应用程序中工作得很好,但是有一点问题,当用户通过表单编辑编辑或创建一行并且用户在表单的模态外单击时,模式关闭并且更改丢失.避免这种行为是否可行?
解决方法
解决了!
只是,一定要在网格编辑中设置模态:true或添加选项,但一定要下载jqGrid进行模态编辑.见http://www.trirand.com/blog/?page_id=6.
这是我的网格(查找//选项),现在模式仅在单击保存或取消按钮时关闭:
- jQuery("#gridTipo").jqGrid(
- {
- url : 'obtenerTipoDetallePorTipo.do?idTipo=0',datatype : "json",colNames : [ 'ID','Codigo','Descripción','Tabla','CodPadre','Nombre','Idioma' ],colModel : [ {
- name : 'id',index : 'id',autowidth:true,hidden : true,width : 90,editable : true,editoptions : {
- readonly : true,size : 10
- }
- },{
- name : 'codigoTipo',index : 'codigoTipo',autowidth : true,formoptions : {
- rowpos : 2,label : "Codigo",elmprefix : "(*)"
- },editrules : {
- required : true
- }
- },{
- name : 'descripcionTipo',index : 'descripcionTipo',editoptions : {
- size : 20
- },formoptions : {
- rowpos : 3,label : "Descripcion",{
- name : 'tabla',index : 'tabla',formoptions : {
- rowpos : 4,label : "Tabla",editrules : {
- required : true
- }
- },{
- name : 'codpadre',index : 'codpadre',size : 25,defaultValue : function() {
- var codPad = jQuery("#codPadreH").val();
- return codPad;
- }
- }
- },{
- name : 'nombre_tipo',index : 'nombre_tipo',formoptions : {
- rowpos : 6,label : "Nombre",{
- name : 'idioma',index : 'idioma',edittype : "select",editoptions : {
- value : "${idiomasDin}"
- },formoptions : {
- rowpos : 7,elmprefix : " "
- }
- } ],rowNum : 10,pager : jQuery('#pgridTipo'),sortname : 'id',sortorder : "desc",viewrecords : true,width : '620',height : "250",editurl : "doPost.do",shrinkToFit:false,caption : "Administracion Tipos"
- }).navGrid('#pgridTipo',{
- add : true,search : false,del : false
- },//options
- { modal: true,height : 220,width : 500,reloadAfterSubmit : true,recreateForm : true,closeAfterEdit : true,beforeInitData : function(FrmGrid_gridTipo) {
- jQuery("#gridTipo").setColProp('codigoTipo',{
- editoptions : {
- readonly : true,size : 20
- }
- });
- jQuery("#gridTipo").setColProp('tabla',size : 20
- }
- });
- jQuery("#gridTipo").trigger('reloadGrid');
- //alert("hola");
- }
- },// edit options
- {
- modal: true,closeAfterAdd : true,{
- editoptions : {
- readonly : false,size : 20
- }
- });
- jQuery("#gridTipo").trigger('reloadGrid');
- //alert("hola");
- },recreateForm : true
- },// add options
- {
- reloadAfterSubmit : false
- },// del options
- {} // search options
- );