Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

isRowSelectable function is not working after factory call

Posted on 2016-11-13
2
Medium Priority
?
140 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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

618 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