2016-04-20 108 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();