开发者

when there is a java exception is throwed, the jqgrid can't run any more

I do not know why there is always this: During the debug process, there is an error thrown in the java,then I can no longer run jqgrid. For example, I deliberately misspelled sql syntax in java, an exception is thrown back And then I query again after a good change can no longer perform to the java program. Displayed on the screen "loading" flash across, jqgrid have not done any. Then I must restart tomcat to debug again. As long as the background of any exception that caused this situation.

Sorry for my poor English.

Is there any way to improve the situation? thanks

Here is my code:

$.ajaxSetup({ cache: false });

var colspan = 5;
//the last modified cell's iRow and iCol
var lastedit = [];
//color array
var colorarray = new Array(['invalid_normal', 'invalid_manual','invalid_swap','invalid_business'],['valid_normal','valid_manual','valid_swap','valid_business']);

$.ajax(     
    { 
       type: "GET",        
       url: "/cbill/routenew/routequerydata.do",        
       data: "",        
       dataType: "json",        
       success: function(result){             

            var colModel = createcolModel(result.colModel); 
            var grid = jQuery("#gridTable");

            grid.jqGrid({   
            jsonReader: {   
                root: "gridModel",      // (2)   
                records: "record",      // (3)   
                repeatitems : false     // (4)   

            },  
            url: '/cbill/routenew/freshgriddata.do',
                datatype: 'json', 
            mtype: "GET",   
            colModel :colModel, 
            pager: "#gridPager",   
            rowNum: 50,   
            rowList: [50,100],                  
            height: 500,   
            loadonce:false,
            //width: 1500,
            //autowidth: true,   
            //colNames: colModelData,
            viewrecords: true,  
            prmNames: {search: 'search'},   //(1)   
            caption: "Route",
                position:"last",                
            multiselect: true,
            multiboxonly:true,
            toppager: true,
            rownumbers:true,
            shrinkToFit:true,
            hidegrid: false


           });

           grid.jqGrid('navGrid','#gridPager',{del:false,add:false,edit:false},{},{},{},
               {
                caption: "Search",   
                Find: "Go!",   
                Reset: "Reset",
                //refresh: true,
                closeAfterSearch: true,   
                multipleSearch: true,   
                groupOps: [{ op: "AND", text: "All" }],
                cloneToTop: true

               }
           ).navButtonAdd('#gridPager_left',{   
               caption:"RT Modify",    
               buttonicon:"ui-icon-newwin", 
               onClickButton: function(){    

                    $("#rowdata").jqGrid('GridUnload');
                    var ids = grid.jqGrid('getGridParam','selarrrow');
                    if (ids.length == 1) {

                    var entirerow;
                        for (var i=0, il=ids.length; i < il; i++) {
                        var entirerow = grid.jqGrid ('getRowData',ids[i]); 
                        }
                        //alert(entirerow.vc2routeno);
                        lastedit = loadComparisonRowData(entirerow, colModel);  

                    }else{
                    alert("Please select one route!");   
                    return false;                       
                    }
               },    
               position:"last"  
            }).navSeparatorAdd("#gridPager_left",{sepclass : 'ui-separator',sepcontent: ''}).navButtonAdd('#gridPager_left',{   
               caption:"State Modify",    
               buttonicon:"ui-icon-newwin", 
               onClickButton: function(){    
                    $("#rowdata").jqGrid('GridUnload');
                    var ids = grid.jqGrid('getGridParam','selarrrow');
                    if (ids.length != 0) {
                    if($("#gridPager_left").find("#vc2subroutecode").val()=='' && $("#pg_gridPager").find("#vc2subroutecode").val()==''){
                        alert("Please enter the sub-route code!");
                        return false;
                    }
                    var rowcells=new Array(); 
                    var vc2updrouteno=new Array(); 

                        for (var i=0, il=ids.length; i < il; i++) {
                        var ent开发者_StackOverflow社区irerow = grid.jqGrid ('getRowData',ids[i]); 
                        rowcells.push(entirerow);
                        vc2updrouteno.push(entirerow.vc2routeno);
                        }
                        loadSelectedRowData(rowcells, vc2updrouteno, colModel);  

                    }else{
                    alert("Please select route!");   
                    return false;                       
                    }
               },    
               position:"last"  
            }); 

            $('#gridPager_left').clone(true).insertBefore('#gridTable_toppager_left') 
            $('#gridTable_toppager_left').remove(); 

            $("#resetSearch").click(function() {
                 var grid = $("#gridTable");     
                 grid.jqGrid('setGridParam',{search:false});      
                 var postData = grid.jqGrid('getGridParam','postData');     
                 $.extend(postData,{filters:""});     
                 // for singe search you should replace the line with     
                 // $.extend(postData,{searchField:"",searchString:"",searchOper:""});      
                 grid.trigger("reloadGrid",[{page:1}]); 
            });                
           //$('.ui-jqgrid-hdiv').hide();

            $("#consoleDlg").dialog({   
                autoOpen: false,       
                modal: false,     
                resizable: true,  
                height: 620,     
                width: 1200,   
                open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); },
                buttons: {  // 
                "Cancel": function() {$("#consoleDlg").dialog("close");},
                "Update" : function(){updateRouteInfo(colModel)},
                "Confirm": updateRouteFlag,
                "I Know": copyToClipboard
                }
            }); 

       },
       error : function(textStatus, errorThrown) {   
        alert("route list error: " + textStatus);   
       }         

}); 

Hi oleg, Thanks for your advice.

In fact, my confusion is because the server-side java cause the error which led to the client jqgrid doesn't run. I do not know if I call grid.jqGrid ('GridUnload', '# gridTable') to solve this problem, because now I do not even know where to put this method, because an exception is thrown on the server side, I do not know what events to capture it and then call this method. I don't know where the exceptions is handled in grid.jqGrid ({/ * parameters */}) when the url'/cbill/routenew/freshgriddata.do' resulted in an error ;

When an java error occurs and I refresh the page, there is an client exception to be thrown below :

error: function (textStatus, errorThrown) { alert ("route list error:" + textStatus); }

Neither the '/ cbill / routenew / routequerydata.do', nor '/ cbill / routenew / freshgriddata.do' is not executed on the server side.

I have two popup windows here to modify some data:

"Update" : function(){updateRouteInfo(colModel)}, "Confirm": updateRouteFlag,

Same as I said above, whenever a exception is thrown in these codes, I can not execute the query and the client exception above is appeard when I refresh the page. (I have several error functions in all code, the java exception will always cause a error on the client side in the frist error function above, I think the error state is saved to jqgrid)

Of course, I try to improve the server-side code in order to avoid the error, but can not avoid all errors. if an exception occurs in the background, the jqgrid program module will not run.

I do not know whether to express exactly what I mean. I want you more help. thanks


The permanent "loading" message means typically that the loading of grid data from the server was started but during some reasons it was exception somewhere in the JavaScript code. I recommend you to use some debugger (for example Developer Tools of the Internet Explorer) to localize the place of the error/exception.

The problem with one attempt to load the data can be because you use the code above more as one time. The problem is following. jqGrid constructs some divs and many other HTML elements over the <table id="gridTable"></table> which you use. So you should call the grid.jqGrid({/*parameters*/}); only once per grid. If you do need to reload the column definition and then the grid on the page you should call GridUnload: grid.jqGrid('GridUnload','#gridTable') and then reassign grid variable: grid = jQuery("#gridTable");. See in the answer the corresponding demo example.

One more remark. I don't recommend you to use $('#gridPager_left').clone(true). Instead of that you can use cloneToTop:true parameter of navGrid:

grid.jqGrid('navGrid','#gridPager',{cloneToTop:true, ...}

To add buttons to the standard bottom pager you should "#gridPager" or '#gridTable_toppager' and not "#gridPager_left" and '#gridTable_toppager_left' like you do. Moreover you should not remove any jqGrid element, just hide it if you don't need it. For example the code $('#gridTable_toppager_left').remove(); seems me danderous.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜