2013-12-20 1 views
0

내 매끄러운 그리드 설정 :Slickgrid 업데이트하지 일관

var records = []; 
    var grid; 
    var columns = [ 
     { id: "ServerName", name: "Server Name", field: "ServerName" }, 
     { id: "DVCurrent", name: "DV Current", field: "DVCurrent", editor: Slick.Editors.LongText }, 
     { id: "DVLast", name: "DV Last", field: "DVLast" }, 
     { id: "PYCurrent", name: "PY Current", field: "PYCurrent", editor: Slick.Editors.LongText }, 
     { id: "PYLast", name: "PY Last", field: "PYLast" }, 
     { id: "PDCurrent", name: "PD Current", field: "PDCurrent", editor: Slick.Editors.LongText }, 
     { id: "PDLast", name: "PD Last", field: "PDLast" } 
    ]; 

    var options = { 
     enableCellNavigation: true, 
     enableColumnReorder: false, 
     forceFitColumns: true, 
     autoEdit: false, 
     editable: true 
    }; 

그리고 격자의 생성 :

grid = new Slick.Grid("#myGrid", records, columns, options); 

내 MVC 컨트롤러에서 데이터를 가져 오는 기능 :

function GetRecords() { 
     $.ajax({ 
      url: '@VirtualPathUtility.ToAbsolute("~/Home/GetRecords")', 
      dataType: 'json', 
      type: 'GET', 
      success: function (data) { 
       records = data; 
       grid.setData(records); 
       grid.invalidate(); 
      } 
     }); 
    } 

페이지가로드 될 때 모든 것이 잘됩니다. 데이터가 반입됩니다. 문제는 저장 버튼을 클릭 할 때 그리드가 다시 업데이트되기를 원할 때 발생합니다.

$('#btnSave').click(function() { 
      $.ajax({ 
       url: '@VirtualPathUtility.ToAbsolute("~/Home/UpdateAllRecords")', 
       dataType: 'json', 
       contentType: "application/json", 
       type: 'POST', 
       data: JSON.stringify(grid.getData()), 
       success: GetRecords 
      }); 
     }); 

단순히 아무 것도하지 않습니다. 작업은 서버 측에서 성공적으로 완료되지만 GetRecords가 실행되지 않는 것처럼 새로 고쳐지지 않습니다. 콘솔 오류가 없습니다.

페이지를 새로 고침하면 업데이트 된 데이터를 가져 오는 중입니다.

답변

1

당신은 아마이 작품을 누락 :

// Refresh the new data rendered 
grid1.updateRowCount(); 
grid1.render(); 

를 작동하지 않는 경우, 당신은 할 수는 async:false에 저장 가진하려고하면 불을 지르고와 새 데이터 세트의 결과를 확인해야합니다. 희망은 도움이 ..