How to refresh Kendo Grid on delete and add row action?

半腔热情 提交于 2019-12-13 04:34:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!