Solved

isRowSelectable function is not working after factory call

Posted on 2016-11-13
2
86 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

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

Suggested Solutions

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

738 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