Solved

isRowSelectable function is not working after factory call

Posted on 2016-11-13
2
12 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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.
This video discusses moving either the default database or any database to a new volume.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now