问题
I have data in the grid but after certain actions like (delete or add) i want to refresh grid , below i have method for delete that is deleting the row in Kendo grid. So i want to refresh grid once delete action is completed. How to achieve that task with below implementation...
So far tried code....
main.html
<div kendo-grid="topRiskGrid" options="topRisksOptions" ></div>
main.ctrl
$scope.topRisksOptions = topRiskGridConfig.getTopRisksGrid();
$scope.topRisksOptions.dataSource = rcsaAssessmentService.getTopRisksGridDataSource($stateParams.assessmentId);
var deleteCallBack = function () {
$scope.topRiskGrid.dataSource.read();
};
$scope.deleteTopRisks = function(key){
rcsaAssessmentFactory.deleteTopRisk(key.riskAssessmentKeyConcernKey,'RS_DELETED').then(function(){
deleteCallBack();
});
}
main.factory
getTopRisksGridDataSource : function(assessmentId) {
return new kendo.data.DataSource({
type : 'json',
transport : {
read : function(options) {
return $http.get('app/assessment/rest/topRisks?riskAssessmentKey=' +assessmentId).success(
function(data) {
options.success(data.riskAssessmentKeyConcernDTOs);
});
}
},
pageSize : 5,
});
}
回答1:
$("#btn_addContact").click(function(e) {
// show the spinner
kendo.ui.progress($("#contactdetailgrid"), true);
$.ajax({
type: "POST",
url: 'ajaxdata/util_projectcontacts.php',
data: data,
dataType: 'text' }).done(function() {
// reload the grid data
$("#contactdetailgrid").data('kendoGrid').dataSource.read();
$("#contactdetailgrid").data('kendoGrid').refresh();
// hide the spinner
kendo.ui.progress($("#contactdetailgrid"), false);
});
});
I do it like this on my pages
来源:https://stackoverflow.com/questions/30847647/how-to-refresh-kendo-grid-on-delete-and-add-row-action