1

I´m developing an application using CodeIgniter and JQuery. I have read here jqgrid error message on delete and here jqGrid error message from server side exception some issues about this problem but the fact is that does not work for me.

In my database I have set some business rules in form of index, checks, etc. I need to customize the "error Status: 'error'. Error code: 500" that the jqGrid returns when I have those types of errors. I´d appreciate any help. Here is my jquery grid code.

<script type="text/javascript">
    var base_url = 'http://localhost/sp/';
    var site_url = 'http://localhost/sp/index.php';
    var url = '';

        $(document).ready(function() {

           var grid = jQuery("#newapi_1351019084").jqGrid({
                    ajaxGridOptions : {type:"POST"},
                       jsonReader : {
                       root:"data",
                       repeatitems: false
                   },
                   ondblClickRow: function(id){
                       dtgLoadButton1();

                        return;
                       },
                    rowList:[10,20,30],
                    viewrecords: true
                   ,url:'http://localhost/sp/index.php/assigment/getData'
,editurl:'http://localhost/sp/index.php/assigment/setData'
,datatype:'json'
,rowNum:'13'
,width:'800'
,height:'300'
,pager: '#pnewapi_1351019084'
,caption:'Control de asignaciones'
,colModel:[
{name:'username',index:'username',label:'Usuario' ,align:'left',width:300,editable:false,edittype:'text',editrules:{required:true}  }
,{name:'StoreName',index:'StoreName',label:'Tienda' ,align:'center',width:200,editable:false,edittype:'text',editrules:{required:true}  }
,{name:'Users_idUsers',index:'Users_idUsers',label:'Usuario' ,align:'center',width:100,hidden:true,editable:true,edittype:'select',editoptions:{value:":Select;5:tienda1;6:tienda2;17:tienda3;18:tienda11",size:10},editrules:{edithidden:true,required:true,integer:true}  }
,{name:'Stores_idStores',index:'Stores_idStores',label:'Tienda' ,align:'center',width:100,hidden:true,editable:true,edittype:'select',editoptions:{value:":Select;1:EA001;3:EA003;4:EA005;5:EA006;6:EA007;7:EA008;8:EA009;9:EA010;10:EA011;11:EA012;12:EA013;13:EA015;14:EA017;15:EA018;16:EA019;17:EA020;18:EA021;19:EA022;20:EA002;21:EA000",size:10},editrules:{edithidden:true,required:true,integer:true}  }
,{name:'SurrugateTurn',index:'SurrugateTurn',label:'SurrugateTurn' ,align:'center',width:100,key:true,hidden:true,editable:true,edittype:'select',editoptions:{value:":Select;1:1;3:3;2:2",size:10},editrules:{hidden:true}  }
]               })
              jQuery("#newapi_1351019084")
            .jqGrid('navGrid',
            '#pnewapi_1351019084',
            {view:false,
            edit:'1',
            add:'1',
            del:'1',
            close:true,
            delfunc: null ,
            search:''
        },
        { recreateForm: true, 
        width : 400 ,
        beforeShowForm : function(form) {

         },
        closeAfterEdit:true }, // edit options

        {  recreateForm: true,
        width : 400,
        closeAfterAdd : true,
         beforeSubmit : function(postdata, formid) {
         var mensaje = '';
         var resultado = true;




          return[resultado,mensaje]; 
        }
        }, /*add options*/

        {mtype: 'POST'} /*delete options*/,
        {sopt: ['eq','cn','ge','le' ] ,     
        multipleSearch: false ,
        showOnLoad : false,
        overlay:false,mtype: 'POST'} /*search options*/
        ).navButtonAdd('#pnewapi_1351019084',
                { caption:'', buttonicon:'ui-icon-extlink', onClickButton:dtgOpenExportdata, position: 'last', title:'Export data', cursor: 'pointer'}
                );
;
        });
</script>

Best regards and thanks for your time,

Community
  • 1
  • 1
Caleb
  • 179
  • 2
  • 17

1 Answers1

4

Assuming the server returns a user-friendly error message with the HTTP 500 response, you can simply to this:

...
{ recreateForm: true, 
    width : 400 ,  //removed the empty beforeShowForm callback
    errorTextFormat:function(data){
      if (data.status == 500) 
        return data.responseText;  // You may need to do some HTML parsing here
    }
    closeAfterEdit:true }, // edit options
...
Jens Neubauer
  • 1,090
  • 1
  • 13
  • 24