Solved

isRowSelectable function is not working after factory call

Posted on 2016-11-13
2
65 Views
Last Modified: 2016-12-01
Hi,
I am using Angular uigrid 3.2.8 in my angular js application. Grid using the ui-grid-selection directive to row selection. I selected few rows with row column state as Submitted.  In the submitApprovedRows method I am getting all the selected rows and making a call to Factory to submit selectedrowinfo to RestApi service and there in the factory method I am changing the State from Submitted to Approved and returning from factory. Then I am using isRowSelectable function to determine which rows are selectable. I want to disable the row selection for all the rows with State as Approved. But it is not working.Row is undefined in isRowSelectable method. But I tested and found that  isRowSelectable working fine if I don't make a call to factory call. So It has everything all the dependencies properly included. But after factory call isRowSelectale function not working .Any suggestion please. Thanks.
Please see the code given below.

$scope.submitApprovedRows = function() {
$scope.selectedGridRows = $scope.gridApi.selection.getSelectedRows();
CRFactory.submitApprovedRowsInfo($scope);
$scope.gridApi.selection.clearSelectedRows();

$scope.gridOptions.isRowSelectable = function(row) {
 if(row.entity.State == "Approved") {
       return false;
  }else {
   return true;
}

};

$scope.gridApi.core.notifyDataChange(uiGridContants.dataChange.OPTIONS);


};

Open in new window

0
Comment
Question by:KavyaVS
2 Comments
 
LVL 27

Accepted Solution

by:
BigRat earned 500 total points
ID: 41885357
First off why is there a definition for a function inside a function? I would have thought that isRowSelectable() would have been declared in the controller rather than in a function which submits data to the server(?)

That said,  sounds like the service is changing the grid - which I suppose it shouldn't - and that you have attached isRowSelectable to a row which doesn't exist. Because version 3 requires you to declare the selected features it would be useful to see these details, as well as what you are doing in the service. I must admit I would have never passed $scope to a service but would have written it as follows
$scope.submitApprovedRows = function() {
     var selectedGridRows = $scope.gridApi.selection.getSelectedRows();
     CRFactory.submitApprovedRowsInfo(selectedGridRows,function (err) {/* do something here */ });
     $scope.gridApi.selection.clearSelectedRows();
}

Open in new window

0
 

Author Closing Comment

by:KavyaVS
ID: 41909669
Thanks
0

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You have this traditional web application that refreshes the whole page each time you navigate and you think it's a good time to convert it to a Single-Page approach. What should you know in advance? Read on, I'll guide you through it.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question