Solved

isRowSelectable function is not working after factory call

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

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…
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.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

770 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