2017-08-08 1 views
1

J'ai un jqGrid et SubGrid lorsque subGridRowExpanded, je veux l'événement unbind développer la ligne et l'icône développer les données de ligne lorsque SubGrid est null. Lorsque j'ai glissé une ligne d'une autre grille vers cette sous-grille, je veux que l'événement bind pour subGridRowExpanded à nouveau ajoute l'icône étendre la ligne à la grille. Comment puis-je faire ceci?comment lier et annuler l'événement dans le sous-réseau

Je délie événement subGridRowExpanded lorsque la charge gridComplete:

function CreateOperationGrid(styleCode, styleSize, styleColorSerial, revNo) { 
    Operation_Grid.jqGrid({ 
     datatype: "json", 
     height: 250, 
     width: null, 
     shrinkToFit: false, 
     rowNum: 100000, 
     rownumbers: true, 
     gridview: false, 
     //========================================== 
     url: "/OpsLink/GetOpDetail", 
     caption: "Operation", 
     postData: { 
      styleCode: styleCode, size: styleSize, serial: styleColorSerial, revNo: revNo 
     }, 
     //mtype: 'POST', 
     colModel: [ 
      { 
       name: "BenchmarkTime", 
       index: "BenchmarkTime", 
       width: 95, 
       label: arrColname.BENCHMARKTIME, 
       align: "center", 
       search: false, 
       sort: false 
      }, 
      { name: "StyleCode", index: "StyleCode", hidden: true }, 
      { name: "StyleSize", index: "StyleSize", hidden: true }, 
      { name: "StyleColorSerial", index: "StyleColorSerial", hidden: true }, 
      { name: "RevNo", index: "RevNo", hidden: true }, 
      { name: "OpRevNo", index: "OpRevNo", hidden: true }, 
      { name: "NewPrevNo", index: "NewPrevNo", hidden: true } 
     ], 
     grouping: true, 
     groupingView: { 
      groupField: ["OpGroupName"], 
      groupColumnShow: [false], 
      groupCollapse: true, 
      plusicon: "ace-icon fa fa-plus", 
      minusicon: "ace-icon fa fa-minus" 
     }, 
     subGrid: true, 
     subGridRowExpanded: function (subgridId, rowId) { 
      var row = Operation_Grid.getRowData(rowId); 
      var sCode = row.StyleCode; 
      var subgridTableId = subgridId + "_t"; 
      jQuery("#" + subgridId).html("<table id='" + subgridTableId + "' class='scroll'></table>"); 
      jQuery("#" + subgridTableId).jqGrid({ 
       url: "/OpsLink/GetProtBomPattern?styleCode=" + sCode, 
       datatype: "json", 
       page: 1, 
       colModel: [ 
        { label: arrOpChilName.OpRevNo, name: "OpRevNo", index: "OpRevNo", width: 80 }, 
        { label: arrOpChilName.OpSerial, name: "OpSerial", index: "OpSerial", width: 80 }, 
        { label: arrOpChilName.OpType, name: "OpType", index: "OpType", width: 80 }, 
        { label: arrOpChilName.ConSumUnit, name: "ConSumUnit", index: "ConSumUnit", width: 80 }, 
        { label: arrOpChilName.UnitConSumTion, name: "UnitConSumTion", index: "UnitConSumTion", width: 80 }, 
        { label: arrOpChilName.PieceQty, name: "PieceQty", index: "PieceQty", width: 80 } 

       ], 
       viewrecords: true, 
       height: "100%", 
       rownumbers: true, 
       multiselect: true, 
       pager: "#jqGridPager" + "_" + subgridId 
      }); 
     }, 
     subGridOptions: { 
      plusicon: "ace-icon fa fa-plus", 
      minusicon: "ace-icon fa fa-minus", 
      openicon: "ui-icon-carat-1-sw", 
      expandOnLoad: false, 
      selectOnExpand: false, 
      reloadOnExpand: false 
     }, 
     gridComplete: function() { 
      Operation_Grid.find('tr[role="row"]').addClass("ui-droppable"); 
      $('td[aria-describedby="Operation_Grid_NewPrevNo"]').each(function() { 
       var x = $(this).html(); 
       if (x === "&nbsp;") { 
        $(this).parent().find('td[aria-describedby="Operation_Grid_subgrid"]').unbind("click").html(""); 
       } 
      }); 
     } 
    }); 
} 

Et je veux enregistrer à nouveau événement:

Operation_Grid.find('tr[id="' + rowDropTo + '"]').find('td[aria-describedby="Operation_Grid_subgrid"]').bind("click").html('<a style="cursor:pointer;"><span class="ui-icon ui-icon-plus"></span></a>'); 

Mais pas courir funtion subGridRowExpanded quand je clique sur l'icône. S'il vous plaît aider, merci

Répondre

1

après deux jours de recherche, j'ai été relind susses comme ça.

  1. avant pus retirer dans un tableau:

currChild [id] = $ (this) .parent() find ('td [aria-describedby = "Operation_Grid_subgrid"]').. clone (vrai, vrai); $ (this) .parent(). Find ('td [aria-describedby = "Operation_Grid_subgrid"]'). Unbind ("click"). Html ("");

  1. bin à nouveau.

    Operation_Grid.find ('tr [id = "' + rowDropTo + '"]'). Find ('td [aria-describedby =' Operation_Grid_subgrid "] '). ReplaceWith (currChild [rowDropTo]);

0

Si vous utilisez Guriddo jqGrid, s'il vous plaît vous référer à notre demo example here

Edit: Une autre solution possible pour votre cas est juste pour afficher et masquer l'icône (balise href où le clic BIND) plutôt que pour lier des événements unbind.