表单 – 在JQgrid中编辑或添加新行时,如何在单击外部模态窗口时避免表单关闭?

前端之家收集整理的这篇文章主要介绍了表单 – 在JQgrid中编辑或添加新行时,如何在单击外部模态窗口时避免表单关闭?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
有没有办法在添加或编辑行时避免表单关闭.
Jqgrid在我们的应用程序中工作得很好,但是有一点问题,当用户通过表单编辑编辑或创建一行并且用户在表单的模态外单击时,模式关闭并且更改丢失.避免这种行为是否可行?

解决方法

解决了!

只是,一定要在网格编辑中设置模态:true或添加选项,但一定要下载jqGrid进行模态编辑.见http://www.trirand.com/blog/?page_id=6.

这是我的网格(查找//选项),现在模式仅在单击保存或取消按钮时关闭

  1. jQuery("#gridTipo").jqGrid(
  2. {
  3.  
  4. url : 'obtenerTipoDetallePorTipo.do?idTipo=0',datatype : "json",colNames : [ 'ID','Codigo','Descripción','Tabla','CodPadre','Nombre','Idioma' ],colModel : [ {
  5. name : 'id',index : 'id',autowidth:true,hidden : true,width : 90,editable : true,editoptions : {
  6. readonly : true,size : 10
  7. }
  8. },{
  9. name : 'codigoTipo',index : 'codigoTipo',autowidth : true,formoptions : {
  10. rowpos : 2,label : "Codigo",elmprefix : "(*)"
  11. },editrules : {
  12. required : true
  13. }
  14. },{
  15. name : 'descripcionTipo',index : 'descripcionTipo',editoptions : {
  16. size : 20
  17. },formoptions : {
  18. rowpos : 3,label : "Descripcion",{
  19. name : 'tabla',index : 'tabla',formoptions : {
  20. rowpos : 4,label : "Tabla",editrules : {
  21. required : true
  22. }
  23.  
  24. },{
  25. name : 'codpadre',index : 'codpadre',size : 25,defaultValue : function() {
  26. var codPad = jQuery("#codPadreH").val();
  27. return codPad;
  28. }
  29. }
  30. },{
  31. name : 'nombre_tipo',index : 'nombre_tipo',formoptions : {
  32. rowpos : 6,label : "Nombre",{
  33. name : 'idioma',index : 'idioma',edittype : "select",editoptions : {
  34. value : "${idiomasDin}"
  35. },formoptions : {
  36. rowpos : 7,elmprefix : "    "
  37. }
  38. } ],rowNum : 10,pager : jQuery('#pgridTipo'),sortname : 'id',sortorder : "desc",viewrecords : true,width : '620',height : "250",editurl : "doPost.do",shrinkToFit:false,caption : "Administracion Tipos"
  39. }).navGrid('#pgridTipo',{
  40. add : true,search : false,del : false
  41. },//options
  42. { modal: true,height : 220,width : 500,reloadAfterSubmit : true,recreateForm : true,closeAfterEdit : true,beforeInitData : function(FrmGrid_gridTipo) {
  43. jQuery("#gridTipo").setColProp('codigoTipo',{
  44. editoptions : {
  45. readonly : true,size : 20
  46. }
  47. });
  48. jQuery("#gridTipo").setColProp('tabla',size : 20
  49. }
  50. });
  51. jQuery("#gridTipo").trigger('reloadGrid');
  52. //alert("hola");
  53. }
  54. },// edit options
  55. {
  56. modal: true,closeAfterAdd : true,{
  57. editoptions : {
  58. readonly : false,size : 20
  59. }
  60. });
  61. jQuery("#gridTipo").trigger('reloadGrid');
  62. //alert("hola");
  63. },recreateForm : true
  64. },// add options
  65. {
  66. reloadAfterSubmit : false
  67. },// del options
  68. {} // search options
  69. );

猜你在找的HTML相关文章