2017-03-05 1 views
0

대량 편집 (한 번에 100 개 행의 인라인 편집)을 할 때 최신 버전의 free-jqgrid에서 도움이 필요합니다. 그것은 JQGrid 4.3.1에서 정말 빨랐습니다. free-jqgrid 4.13.6으로 업그레이드 한 후에는 매우 느립니다. 나는 비슷한 예를 썼다. 이 독립 실행 형 예제는 성능이 나쁘지 않습니다. 하지만 내 응용 프로그램에서 인라인 편집을 수행하는 데 왜 시간이 오래 걸리는 지 잘 모르겠습니다. 어떤 힌트라도 도움이 될 것입니다. 이 예제에서는 다중 선택 확인란 (표의 왼쪽 위 모서리에 있음)을 확인한 다음 (상단의) 단추를 클릭합니다. 기본적으로 인라인 편집을 할 때 모든 요소가 고려되는지 이해하려고합니다.free-jqgrid에서 대량 편집 성능

참고 : 이제는 단일 행 인라인 편집에도 2-3 초가 소요됨을 알게되었습니다. 4.3.1에서 정말 빠릅니다.

<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title>http://stackoverflow.com/q/27617764/315935</title> 
    <meta name="author" content="Oleg Kiriljuk"> 
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/redmond/jquery-ui.min.css"> 
    <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css"> 
    <!--<link rel="stylesheet" href="jqGrid/css/ui.jqgrid.css">--> 
    <link rel="stylesheet" href="http://rawgit.com/free-jqgrid/jqGrid/master/css/ui.jqgrid.css"> 
    <style type="text/css"> 
     html, body { font-size: 75%; } 
    </style> 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> 
    <script type="text/javascript"> 
     $.jgrid = $.jgrid || {}; 
     $.jgrid.no_legacy_api = true; 
     $.jgrid.useJSON = true; 
    </script> 
    <script src="http://rawgit.com/free-jqgrid/jqGrid/master/js/jquery.jqgrid.src.js"></script> 
    <!--<script src="jqGrid/js/jquery.jqGrid.src.js"></script>--> 
    <script type="text/javascript"> 
    //<![CDATA[ 
     /*global $ */ 
     /*jslint eqeq: true, browser: true, plusplus: true */ 
     $(function() { 
      "use strict"; 
      var $grid = $("#list"), 
       gridData, 
       startTime, 
       measureTime = false, 
       timeInterval; 

      var date = new Date(), t = Object.prototype.toString.call(date), t1 = String(date); 

      //alert("start to generate the data"); 
      // gridData = getGridData(100); 
     // console.log(gridData); 
      //alert("start to fill the grid") 
      startTime = new Date(); 
      $grid.jqGrid({ 
       datatype: 'json', 
     url: 'https://api.myjson.com/bins/efhbt', 
     mtype: 'GET', 
       colNames: ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm'], 
     colModel: [ 
        { name: "aa", label: "c01" }, 
        { name: "bb", label: "c02" }, 
        { name: "cc", label: "c03" }, 
        { name: "dd", label: "c04" }, 
        { name: "ee", label: "c05" }, 
        { name: "ff", label: "c06" }, 
        { name: "gg", label: "c07", editable: true, stype: 'select', formatter: 'select', 
      edittype: 'select', editoptions: { 
       value: 'Select:Select;Y:Yes;N:No', 
       multiple: false 
      } 
      }, 
        { name: "hh", label: "c08", editable: true, stype: 'select', formatter: 'select', 
      edittype: 'select', editoptions: { 
       value: 'Select:Select;Y:Yes;N:No', 
       multiple: false 
      } 
      }, 
        { name: "ii", label: "c09", editable: true, stype: 'select', formatter: 'select', 
      edittype: 'select', editoptions: { 
       value: 'Select:Select;Y:Yes;N:No', 
       multiple: false 
      } 
      }, 
        { name: "jj", label: "c10", editable: true }, 
        { name: "kk", label: "c11", editable: true }, 
        { name: "ll", label: "c12", editable: true }, 
        { name: "mm", label: "c13", editable: true } 
       ], 
       cmTemplate: { width: 100, autoResizable: true }, 
       rowNum: 1000, 
     records: 1000, 
       rownumWidth: 40, 
       rowList: [20, 100, 1000, 10000, "100000:All"], 
       viewrecords: true, 
       rownumbers: true, 
       toppager: false, 
       pager: false, 
       shrinkToFit: false, 
     multiselect: true, 
     editurl: 'clientArray', 
     loadonce: true, 
       onSortCol: function() { 
        startTime = new Date(); 
        measureTime = true; 
       }, 
     /*onSelectRow: function (rowid) { 
        var $self = $(this), 
         savedRow = $self.jqGrid("getGridParam", "savedRow"); 
        if (savedRow.length > 0) { 
         $self.jqGrid("restoreRow", savedRow[0].id); 
        } 
        $self.jqGrid("editRow", rowid); 
       },*/ 
       loadComplete: function() { 
        if (measureTime) { 
         setTimeout(function() { 
          alert("Total loading time: " + timeInterval + "ms"); 
         }, 50); 
         measureTime = false; 
        } 
       }, 
       autoencode: true, 
       caption: "Shows the performance of resizing. Make double-click on the column resizer" 
      }).jqGrid("filterToolbar", { 
        beforeSearch: function() { 
         startTime = new Date(); 
         measureTime = true; 
         return false; // allow filtering 
        } 
      }).jqGrid("gridResize"); 

      timeInterval = new Date() - startTime; 
      setTimeout(function() { 
       // alert("Total time: " + timeInterval + "ms"); 
      }, 50); 




     // On Click Of Button 
     $("#Change_Value").click(function() { 
     var v = $("#name").val(); 
     var myGrid = $("#list"); 
     var selRowIds = myGrid.jqGrid("getGridParam", "selarrrow"); 
     //alert(selRowId.length); 
     for (var i = 0; i < selRowIds.length; i++) { 
      //rowData = myGrid.jqGrid("getLocalRow", selRowIds[i]); 
      // one can uses the data here 
      myGrid.jqGrid("editRow", selRowIds[i], true); 
     } 
     }); 


     }); 
    //]]> 
    </script> 
</head> 
<body> 
    <div> 
    <input type="text" name="name" id="name" /> 
    <input type="button" name="Change_Value" id="Change_Value" value="Change Value" /> 
    </div> 
    <div> 
    <table id="list"></table> 

    </div> 
</body> 
</html> 

답변

1

은 하나 개의 요소의 모든 변화는 모든 기존의 웹 브라우저 reflow에 따라 페이지 및 에 많은 변화를 생산하기 때문에 "대량 편집"(한 번에 100 행의 인라인 편집) 일반적으로 나쁜 요소. 또한 사용자가 볼 수있는 약 100 개의 행을 가진 그리드 표시 (모니터의 자연스러운 제한 때문에)는 성능을 추가로 감소시킵니다.

myGrid.hide(); // !!! new line 
for (var i = 0; i < selRowIds.length; i++) { 
    myGrid.jqGrid("editRow", selRowIds[i], true); 
} 
myGrid.show(); // !!! new line 

은 25 행으로 지역 페이징을 사용하는 경우, 같은 :

난 그냥 "대량 편집"후 "대량 편집"및 jQuery.show 전에 jQuery.hide의 호출을 포함 another onethe initial demo의 성능 비교 the next demo에 추가하면 페이지의 성능이 추가로 향상됩니다. 초기 데모에서 100 행 편집 시작은 약 1065ms, 이전에 숨겨진 그리드를 편집하는 데모는 330ms, 25 행 (로컬 페이징) 편집에는 90ms가 걸립니다.

UPDATE : 당신은 그리드에서 냉동 열을 사용 경우에 당신은 당신이 editRow 전화 루프, 전 destroyFrozenColumns의 호출에 의해 냉동 열을 파괴해야 다음 setFrozenColumns의 새로운 호출에 의해 고정 된 열을 다시 작성하십시오. 추가로 성능을 향상시켜야합니다.

+0

나는 100 개의 행을 보여주는 것이 정말 나쁜 생각이라는 것을 완전히 이해합니다. 내 경우에는 약 5000 행의 검색 결과가 있습니다. Si는 클라이언트 당 100 개의 행을 표시해야합니다. 4.13으로 업그레이드 한 후에는 성능이 너무 느립니다. 한 번에 100 줄로 빠르게 할 수있는 일을 이해하려고 노력했습니다. 나는 쇼/숨기기와 함께 시도하고 게시 유지. 감사. – SKumar

+0

예, 성능이 향상되었습니다. 나는 (실제로 기술적으로 이해하려고 노력하면서) 숨어서 보여줌으로써 어떻게 이런 일이 발생할 수 있는지 궁금하다. 그 점에 대해 고맙습니다. 그러나 우리는 여전히 생산/준비 환경에서 동일한 양의 파일이 DEV보다 빠르다는 것을 알 수 있습니다. 참고 : 모든 하드웨어 구성은 동일합니다. 또한 냉동 된 컬럼의 높이에 문제가 있다는 것을 알았습니다. 모든 roe이 편집 된 후 DIV (고정 된 열)의 높이는 te grid보다 약 20px 더 큽니다. 나는 데모 예제에서 그것을 시도하고 업데이트 할 것이다. – SKumar

+0

@ 스쿠마 : 환영합니다! ** 웹 브라우저 리플 로우에 대해 [기사] (https://developers.google.com/speed/articles/reflow) **를 읽으십니까? 페이지에서 여러 번 변경 한 경우 느린 성능의 이유 *를 설명합니다. 숨겨진 요소의 변경은 리플 로우 작업의 일부를 줄입니다. 그리드에서 고정 열을 사용한다면, 루프 앞의'destroyFrozenColumns' 호출에 의해 고정 열을 파괴해야합니다. 여기서'editRow'를 호출 한 다음'setFrozenColumns' 호출에 의해 고정 열을 다시 생성해야합니다. 추가로 성능을 향상시켜야합니다. – Oleg

관련 문제