Here i want to dynamically update the display name or field of grid headers according to any user input value.
<html ng-app="myApp">
<head lang="en">
<meta charset="utf-8">
<title>Getting Started With ngGrid Example</title>
<link rel="stylesheet" type="text/css" href="ng-grid.css" />
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="jquery-1.8.2.js"></script>
<script type="text/javascript" src="angular.js"></script>
<script type="text/javascript" src="ng-grid-1.3.2.js"></script>
<script type="text/javascript">
var app = angular.module('myApp', ['ngGrid']);
app.controller('MyCtrl', function($scope) {
$scope.myData = [{name: "Moroni", age: 50},
{name: "Tiancum", age: 43},
{name: "Jacob", age: 27},
{name: "Nephi", age: 29},
{name: "Enos", age: 34}];
$scope.gridOptions = {
data: 'myData',
columnDefs: [{field: 'name', displayName: 'Name'},
{field:'age', displayName:'Age', cellTemplate: '<div ng-class="{red: row.getProperty(col.field) > 40}"><div class="ngCellText">{{row.getProperty(col.field)}}</div></div>'}]
};
});
</script>
</head>
<body ng-controller="MyCtrl">
<div class="gridStyle" ng-grid="gridOptions"></div>
</body>
</html>
Now my requirement is:-
IN HTML There would be something like
A Dropdown in which there are my All Grid Headers value. ANd corresponding there would be a input box
When user select any particular grid header from dropdown, then corresponding input value get mapped to that header , and my grid get also updated according to modified header.
- Guys please help me, i am really get stuck in doing this in angular and this is really very important for me
$scope.gridOptions.columnDefsarray when thing changes is what you want? You can do$scope.$watchon scope variable linked to the dropdown box and perform this changes in the watch callback?