Last active
December 19, 2015 04:59
-
-
Save telagraphic/5901394 to your computer and use it in GitHub Desktop.
A user fills in a search form and the grid gets populated based on their input. Depending on their role, certain columns should be hidden. The issue is that $scope.gridOptions is initially loaded upon page load and the code below doesn't update the grid when I have removed column from the columnsDefs array in the gridOptions object. I haven't f…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scope.getBrokerSales = function () { | |
var searchCriteria = { | |
.... | |
}; | |
BrokerSalesService.executeBrokerSalesSearch(searchCriteria).then(function (data) { | |
resetColumnDefs(); | |
$scope.brokerSaleResults = data.BrokerSaleResults; | |
}); | |
}; | |
function resetColumnDefs() { | |
if (userRole != Admin) { | |
$scope.gridOptions.columnDefs.splice(5, 1); | |
} | |
} | |
$scope.gridOptions = { | |
data: 'brokerSaleResults', | |
canSelectRows: false, | |
displaySelectionCheckbox: false, | |
footerRowHeight: 35, | |
showFooter: true, | |
showGroupPanel: true, | |
showColumnMenu: true, | |
showFilter: true, | |
enableColumnResize: true, | |
sortInfo: { fields: ['SignupDate'], directions: ['asc'] }, | |
columnDefs: [ | |
{ field: 'Broker', displayName: 'Broker', width: '120' }, | |
{ field: 'AgentName', displayName: 'Agent Name', width: '120' }, | |
{ field: 'AgentCode', displayName: 'Agent Code', width: '120' }, | |
{ field: 'ConfirmationNumber', displayName: 'Confirmation #', width: '120' }, | |
{ field: 'AccountType', displayName: 'Account Type', width: '110' }, | |
{ field: 'AccountNumber', displayName: 'Account Number', width: '160' } | |
] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why don't you conditionally display the
ng-grid
say usingng-switch
? As in, when the page loads, set the when clause to "false". Once you are certain of the type of the user, set it to true - since you are usingng-switch
I expect that theng-grid
directive is not compiled until the when clause becomes true... Does that make sense?