forked from angular-ui/ui-grid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain2.js
48 lines (41 loc) · 2.98 KB
/
main2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
function userController($scope, $timeout) {
$scope.myData = [{ 'Sku': 'C-2820164', 'Vendor': 'NEWB', 'SeasonCode': {'test': 'nestedObject2'}, 'Mfg_Id': '573-9880954', 'UPC': '822860449228', 'test': '822860449228' },
{ 'Sku': 'J-8555462', 'Vendor': 'NIKE', 'SeasonCode': {'test': 'nestedObject'}, 'Mfg_Id': '780-8855467', 'UPC': '043208523549', 'test': '822860449228' },
{ 'Sku': 'K-5312708', 'Vendor': 'REEB', 'SeasonCode': {'test': 'nestedObject'}, 'Mfg_Id': '355-6906843', 'UPC': '229487568922', 'test': '822860449228' },
{ 'Sku': 'W-4295255', 'Vendor': 'REEB', 'SeasonCode': {'test': 'nestedObject'}, 'Mfg_Id': '861-4929378', 'UPC': '644134774391', 'test': '822860449228' },
{ 'Sku': 'X-9829445', 'Vendor': 'DOCK', 'SeasonCode': {'test': 'nestedObject2'}, 'Mfg_Id': '298-5235913', 'UPC': '872941679110', 'test': '822860449228' },
{ 'Sku': 'H-2415929', 'Vendor': 'REEB', 'SeasonCode': {'test': 'nestedObject'}, 'Mfg_Id': '615-8231520', 'UPC': '310547300561', 'test': '822860449228' },
{ 'Sku': 'X-2718366', 'Vendor': 'MERR', 'SeasonCode': {'test': 'nestedObject2'}, 'Mfg_Id': '920-2961971', 'UPC': '157891269493', 'test': '822860449228' },
{ 'Sku': 'Q-1505237', 'Vendor': 'AX', 'SeasonCode': {'test': 'nestedObject'}, 'Mfg_Id': '371-6918101', 'UPC': '553657492213', 'test': '822860449228' },
{ 'Sku': 'M-1626429', 'Vendor': 'REEB', 'SeasonCode': {'test': 'nestedObject'}, 'Mfg_Id': '242-5856618', 'UPC': '029388467459', 'test': '822860449228' },
{ 'Sku': 'Y-1914652', 'Vendor': 'LEVI', 'SeasonCode': {'test': 'nestedObject'}, 'Mfg_Id': '80-9194110', 'UPC': '433360049369', 'test': '822860449228' }];
$scope.selections = [];
$scope.gridOptions = {
data: 'myData',
selectedItems: $scope.selections,
enableRowSelection: true,
multiSelect: true,
enableRowReordering: false,
enableCellSelection: true,
enableCellEdit: true,
showGroupPanel: true,
columnDefs: 'myDefs'
};
$scope.callMethod = function(){
angular.forEach($scope.myData, function(item, index){
if(typeof item == 'object' && item.hasOwnProperty('SeasonCode')){
if(item.SeasonCode.hasOwnProperty('test') && item.SeasonCode.test == 'nestedObject2'){
$scope.selections.push(item);
}
}
});
};
$scope.changeDefs = function(){
$scope.myDefs = [{ field: 'Sku', displayName: 'My Sku', width: '40%' },
{ field: 'Vendor', displayName: 'Supplier', editableCellTemplate: '<select><option>hello</option><option>test</option></select>' },
{ field: 'SeasonCode.test', displayName: 'My SeasonCode', cellTemplate: '<input style="width:100%;height:100%;" class="ui-widget input" type="text" ng-readonly="!row.selected" ng-model="COL_FIELD"/>' },
{ field: 'Mfg_Id', displayName: 'Manufacturer ID', width:'100px' },
{ field: 'UPC', displayName: 'Bar Code', width:200 }];
};
$scope.callMethod();
}