ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

Unable to Bind array object to the UI-Grid

Open Shreeshag opened this issue 10 years ago • 8 comments

I have data as bellow :

$scope.gridOptions = {
columnDefs: [
                         { name: 'users', displayName:'Users'}
                     ]
};

$scope.gridOptions.data = ["users": [{"ABC","ADF","PQR"}]];

I am unable to display "users" data in single cell.

Any ides, how to solve this?

Shreeshag avatar Feb 17 '16 08:02 Shreeshag

your code has some error, change the nameto fieldlike this:

$scope.gridOptions = {
columnDefs: [
                         { filed: 'users', displayName:'Users'}
                     ]
};

JavaBasketball avatar Feb 17 '16 09:02 JavaBasketball

Hi please try this code I just checked it in grid it will work fine

$scope.gridOptions = {
columnDefs: [
                         { field: 'Name', displayName:'Users'}
                     ],

                     onRegisterApi: function(gridApi){
                                        $scope.gridApi = gridApi;
    }

};

$scope.gridOptions.data = [{"Name": "ABC"}, {"Name": "ADF"}, {"Name": "PQR"}];

shadkhan avatar Feb 17 '16 09:02 shadkhan

@Vinodang

I think there is no error in my code, its work me for other data, but i am unable to bind Array in single cell.

Shreeshag avatar Feb 17 '16 09:02 Shreeshag

@shadkhan

yup, let me try :-)

Shreeshag avatar Feb 17 '16 09:02 Shreeshag

@shadkhan

If i use $scope.gridOptions.data = [{"Name": "ABC"}, {"Name": "ADF"}, {"Name": "PQR"}];

It will create new row for each name, but i am looking all 3 values in single cell like: 'ABC,ADF,PQR'

Shreeshag avatar Feb 17 '16 09:02 Shreeshag

Some how i done with "cellFilter: " Thank you

Shreeshag avatar Feb 17 '16 10:02 Shreeshag

@Shreeshag could you please show your fixed code?

JavaBasketball avatar Feb 18 '16 10:02 JavaBasketball

I have done with

.filter('users', function() { 
                     ....
                     ....
                     ....
                     ....
})

Shreeshag avatar Feb 18 '16 16:02 Shreeshag