2016-06-08 12 views
0

Warum wird der onClick automatisch aufgerufen und nicht wenn ich auf die Zelle klicke? Ich möchte in der Lage sein, auf die Zelle zu klicken und dann die Seite zu laden. Code:Warum wird die jqgrid-Formatierungsoption "onClick" automatisch geladen und nicht, wenn auf die Zelle geklickt wird?

colNames:['Name','Status', 'Created On', 'Update By', 'Updated On', 'RetentionDays','ValidityTime','Edit'], 
    colModel:[ 
       { 
        name: 'name', width:100,editable: true, edittype:'select', 

        formatter: "dynamicLink", 
        "formatoptions":{"onClick":$("#contents").load("jsp/consumers.jsp")}, 

        xmlmap: function (obj) { 
         return $(obj).attr('name'); 
        } 

       }, 

EDIT:

$ (document) .ready (function() {

calEventTypes(eventTypesUrl); 
$("#eventsDiv").click(function(){   
    $('#eventsErrorDiv').css("visibility", "hidden"); 
    $('#eventsErrorDiv').css("display", "none");  

}); 
$("#jqGrid").jqGrid({ 
    hidegrid: false,    
    datatype: 'xmlstring', 
    datastr : xmlData, 
    colNames:['Name','Status', 'Created On', 'Update By', 'Updated On', 'RetentionDays','ValidityTime','Edit'], 
    colModel:[ 
       { 
        name: 'name', width:100,editable: true, edittype:'select', 

        formatter: "showlink", idName: null, 
        onClick: function (options) { 
         alert("It's clicked!\nI'm going to Google..."); 
         window.location = "https://www.google.com/"; 

        }, 

        xmlmap: function (obj) { 
         return $(obj).attr('name'); 
        } 
       }, 

Antwort

1

Der Handler in einer Funktion eingewickelt werden muss:

 "formatoptions":{"onClick": function() { 
      $("#contents").load("jsp/consumers.jsp"); 
     }}, 
+0

Wenn ich das mit Formatierer mache: "showlink", dann lädt mein jsp link nicht und ich werde zu "original URL +? Id = (rowId)" gebracht. Ich möchte abl sein Um zur angegebenen URL-Auslastung zu navigieren, wie kann ich dies erreichen? –

+0

@BellaWesley Ich weiß es nicht; Ich weiß nichts über jqgrid. – Pointy