Click here to Skip to main content
15,888,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a kendo grid with few columns(let's name them as A,B,C,D) where data in column A & B I am getting from the database. Column C is a drop down and..

my requirement is upon change of drop-down in column C, I should perform some sort of calculations on the values of column B & C(i.e, drop-down value) and the result should be updated in column D.

Till the drop-down part my code is working very well. What I cannot achieve is to get the value of column B under change of event of drop down. I tried using $scope there but to no avail. ""I hope I am able to convey my issue clearly"..


Any help would be highly appreciated......

What I have tried:

<select kendo-drop-down-list
                k-options="roleOptions"
                style="width: 100%"></select>
    
    

    

    <script>
        angular.module('PerformanceApp', ["kendo.directives"]).controller('PerformanceController', function ($scope, $http, $q) {

            $scope.Roles = {
                serverFiltering: true,
                transport: {
                    read: {
                        url: "Performance/GetRoles"
                    }
                }
            }

            $scope.roleOptions = {
                optionLabel: "Select Role..",
                dataSource: $scope.Roles,
                dataTextField: "Role",
                dataValueField: "Id",
                change: function (e) {
                    console.log(e.sender.value());
                    var aa = $scope.GetServerData(e.sender.value());
                    aa.then(function (data) {
                        $scope.gridData.data(data);
                    });
                }
            };

            $scope.gridData = new kendo.data.DataSource({
                group: { field: "Category" }
            });

            $scope.gridColumns = [
                    //{ field: "Category", title: "Category" },
                    { field: "CategoryParameter", title: "Category Parameter" },
                    { field: "TI", title: "Team/Individual" },
                    { field: "Score", title: "Score" },
                    { field: "YourRating", title: "Your Rating", template: '<select kendo-drop-down-list k-options="yourRating" style="width: 100%"></select>' },
                    { field: "YourComment", title: "Your Comment", editable: true },
                    { field: "ManagerRating", title: "Manager Rating", template: '<select kendo-drop-down-list k-options="managerRating" style="width: 100%"></select>' },
                    { field: "ManagerComment", title: "Manager Comment", editable: true },
                    { field: "IWeightage", title: "Individual Weightage", template: "" },
                    { field: "MWeightage", title: "Manager Weightage", template: "" }
            ];

            $scope.ratingDataSource = [
                    { Text: 1, Value: 1 },
                    { Text: 2, Value: 2 },
                    { Text: 3, Value: 3 },
                    { Text: 4, Value: 4 },
                    { Text: 5, Value: 5 },
            ];

            $scope.yourRating = {
                dataTextField: "Text",
                dataValueField: "Value",
                dataSource: $scope.ratingDataSource,
                change: function (e) {
                    debugger;
                    //Here I want the value of column "Score"
                    console.log(parseInt(this.value()));
                }
            };

            $scope.managerRating = {
                dataTextField: "Text",
                dataValueField: "Value",
                dataSource: $scope.ratingDataSource,
                change: function (e) {
                    console.log(parseInt(this.value()));
                }
            };

            $scope.GetServerData = function (value) {
                var deferred = $q.defer();
                $http({
                    method: 'GET',
                    url: '/Performance/GetInitialValues',
                    params: { roleId: value }
                })
                .success(function (data) {
                    console.log(data);
                    deferred.resolve(data);
                });
                return deferred.promise;
            }
        });

    </script>
Posted
Updated 12-Dec-16 7:07am
v6
Comments
Andy Lanng 12-Dec-16 4:50am    
I cannot see from your code snippet any details of your grid or how you add the combobox. This makes things tricky. I have no idea what you might be missing.
Please use the Improve Question button and include a little more detail.

It is trivial to get the data from the grid but it depends on how you are creating it
Member 11579819 12-Dec-16 12:33pm    
Hi.. I updated the question. Sorry for not formatting it in proper way as in that was making only little code available to view. have a look on this. And let me know if you can help me in any way
Andy Lanng 12-Dec-16 12:53pm    
Yeah, I tried too. quite odd. I've just put plain text on it :S
Member 11579819 12-Dec-16 12:59pm    
Any suggestions on this
Member 11579819 12-Dec-16 13:01pm    
Kendo grid missed here.. It looks something like this:

"" kendo-grid="performanceGrid"
k-data-source="gridData"
k-columns="gridColumns" ""

1 solution

first you need an event (I'm guessing you just haven't written it in yet).

JavaScript
$scope.gridColumns = [
   { field: "CategoryParameter", title: "Category Parameter" },
   { field: "TI", title: "Team/Individual" },
   { field: "Score", title: "Score" },
   { field: "YourRating", title: "Your Rating", template: '<select kendo-drop-down-list k-options="yourRating" style="width: 100%" ng-change="ratingChange(#= uid #)"></select>' },
   { field: "YourComment", title: "Your Comment", editable: true },
   { field: "ManagerRating", title: "Manager Rating", template: '<select kendo-drop-down-list k-options="managerRating" style="width: 100%"  ng-change="mRatingChange(#= uid #)"></select>' },
   { field: "ManagerComment", title: "Manager Comment", editable: true },
   { field: "IWeightage", title: "Individual Weightage", template: "" },
   { field: "MWeightage", title: "Manager Weightage", template: "" }
            ];


Then, with the handlers taking in the uid it pretty easy:

JavaScript
$scope.rateingChanged = function(uid){
    // if you use the angular kendo grid (and you do) then it's tag is available on the scope
    var rating = $scope.YouGridHere.dataSource.getByUid(get).get("YourRating");
    $scope.YouGridHere.dataSource.getByUid(uid).set("YourPropHere", rating );
}
$scope.mRateingChanged = function(uid){
    var rating = $scope.YouGridHere.dataSource.getByUid(get).get("ManagerRating");
    $scope.YouGridHere.dataSource.getByUid(uid).set("YourPropHere", rating );
}


Anyway, you get the idea :)
 
Share this answer
 
Comments
Member 11579819 12-Dec-16 13:56pm    
How we can use ng-change without ng-model...
And if i am supposed to ng-model then where it should be??
Andy Lanng 12-Dec-16 14:03pm    
I would have though that kendo-drop-down-list would have implemented a model for that.

You could implement a model yourself. The grid should templates should get compiled at run time. If not, you can do it yourself.

You could hang the ng-change and go for onchange?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900