2016-04-20 155 views
0

我有劍道網格我可以更新或刪除它上面的行。但問題是我無法在更新或刪除行後立即刷新kendo網格,但是當點擊f5重新加載時效果很好。我嘗試了很多方法,它不起作用。更新或刪除後無法重新加載劍道網格

$.post(LogstimeEditConstants.urlLogstimeEditRead, { projectId: projectid, userId: userid }, 
      function (result) { 
       objdata = eval(result.data); 
       defaultProjectId = result.defaultProjectId; 
      }); 
     var dslogstime = new kendo.data.DataSource({ 
      data: objdata, 
      schema: { 
       model: { 
        id: "Id", 
        fields: { 
         Id: { required: true }, 
         ProjectID: { defaultValue: defaultProjectId }, 
         WorkDate: { type: "date", defaultValue: dateselect }, 
         TaskId: { defaultValue: defaultTaskId }, 
         WorkHours: { type: "number", defaultValue: "0.5" }, 
         Description: {}, 
         IsDelete: { type: "boolean", defaultValue: false } 
        } 
       } 
      }, 
      sort: [{ field: "ProjectID", dir: "asc" }] 
     }); 
     timelogGrid = $("#tleditgrid").kendoGrid({ 
      dataSource: dslogstime, 
      scrollable: true, 
      editable: "inline", 
    }); 

$("#savebutton").click(function (e){ 
// Remove Logstime 
     $.ajaxSetup({ async: false }); 
     for (var i = 0; i < deleteTimeLogsData.length; i++) { 
      if (deleteTimeLogsData[i].IsDelete === true) { 
       var timelogsId = deleteTimeLogsData[i].Id; 
       $.post(LogstimeEditConstants.urlLogstimeDelete, { logstimeId: timelogsId }, 
        function (result) { 
          $.post(LogstimeEditConstants.urlLogstimeEditRead, { editType: edittype, projectId: projectid, selectDay: selectday, selectMonth: selectmonth, userId: userid }, 
          function (result) { 
           objdata = eval(result.data); 
           defaultProjectId = result.defaultProjectId; 
          }); 
          timelogGrid.dataSource.read(); 
          timelogGrid.refresh(); 
         } 
        }); 
      } 
     } 
}); 

請幫助我,謝謝。刷新前 這意味着你必須把接下來的兩行響應

timelogGrid內;

回答

0

嘗試在$。員額(LogstimeEditConstants,... 重新分配timelogGrid.dataSource.data = objdata。 .dataSource.read(); timelogGrid.refresh();