This is a migrated thread and some comments may be shown as answers.

Changing windows location from custom grid button

3 Answers 152 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Douglas
Top achievements
Rank 1
Douglas asked on 06 Oct 2015, 01:39 PM

I have the following custom grid row button and (using Angular) code:

 

text: "Assign",
click: function (e) {
var tr = $(e.target).closest("tr");
var data = this.dataItem(tr);
authMaintServices.setSelectedRole(data);
$window.location = '#/roleAssignments';
}

In at least IE11, the $window.location works but in Google Chrome it goes nowhere.  Does anyone know how I can get this to work properly in both IE and Chrome?  I have tried the angular $location.path(...) and that does not work in either browser.

 

Thanks for the help.

3 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 08 Oct 2015, 07:25 AM
Hi Douglas,

Can you please refer to the following example, which seems to work correctly on my side:
<!DOCTYPE html>
<html>
<head>
    <style>html { font-size: 14px; font-family: Arial, Helvetica, sans-serif; }</style>
    <title></title>
    <link rel="stylesheet" href="//kendo.cdn.telerik.com/2015.3.930/styles/kendo.common.min.css" />
    <link rel="stylesheet" href="//kendo.cdn.telerik.com/2015.3.930/styles/kendo.uniform.min.css" />
 
    <script src="//kendo.cdn.telerik.com/2015.3.930/js/jquery.min.js"></script>
    <script src="//kendo.cdn.telerik.com/2015.3.930/js/angular.min.js"></script>
    <script src="//kendo.cdn.telerik.com/2015.3.930/js/kendo.all.min.js"></script>
</head>
<body>
<div id="example" ng-app="KendoDemos">
    <div class="demo-section k-content" ng-controller="MyCtrl">
        <div>
            <h4>Basic Button</h4>
            <p>
                <kendo-button class="k-primary" ng-click="onClick1()">Primary Button</kendo-button>               
            </p>
    </div>
         
</div>
 
<script>
  angular.module("KendoDemos", [ "kendo.directives" ])
      .controller("MyCtrl", function($scope, $window){
          $scope.onClick1 = function() {
            $window.location = "/someCustomUrl";
          };
      })
</script>
</body>
</html>

If you continue to experience problems with this, please provide a simplified version of your code, so we can test it locally.


Regards,
Konstantin Dikov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Douglas
Top achievements
Rank 1
answered on 08 Oct 2015, 08:01 PM
Doing it that way is no problem.  The difference is that the button I am using is a custom button on the grid – next to edit and delete.  For some reason that works differently than just a standalone button, which we also do and that does work OK.  The grid button also does not seem to recognize $scope.
0
Konstantin Dikov
Telerik team
answered on 12 Oct 2015, 12:22 PM
Hi Douglas,

The click handler for the button will not recognize the $scope, but you could use the following approach for getting reference to the scope:
command: [{
    name: "customButton",
    click: $scope.clickHandler
}]
 
....
 
 
$scope.clickHandler = function (e) {
    var scope = this.$angular_scope;
    var winObj = scope.returnWindow();
    winObj.location = "/RadControlsWebSite47/_Grid/z_TempPage/KendoTest/Grid.html";
    return false;
}
 
$scope.returnWindow = function () {
    return $window;
}

If any further assistance is needed, please provide a dojo example with your scenario, so we can have better idea of it.


Regards,
Konstantin Dikov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Douglas
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Douglas
Top achievements
Rank 1
Share this question
or