2

I have a column with text fields in my ui grid. I need the last two cells of the column to contain a dropbox. I am not sure how to do this the best way. I am using bootstrap and angularjs for the grid and data within the grid.

Here is where I declare the grid within the html file:

<div class="modal-body">

    <div id="gridTest" ui-grid="gridOptions" class="grid"></div>

</div>

Here is where I setup the data for the columns and the textfields for the column I am talking about:

$scope.gridOptions = {
        showGridFooter: true,
        enableHorizontalScrollbar: 0,
        showColumnFooter: false,
        enableFiltering: false,
        enableColumnMenus: false,
        enableGridMenu: false,
        columnDefs: [
                { field: 'empty', width: '34%', displayName: ''},
                { field: 'modified', width: '34%', displayName: 'Modified', cellTemplate: '<input class="text-test" type="text">'},
                { field: 'original', width: '34%', displayName: 'Originals', cellTemplate: '<div style="text-align:center">{{COL_FIELD CUSTOM_FILTERS}}</div>'},

        ],



        data: [                 
                                {
                                    "empty":"Number of Employees(Daily)",
                                    "modified": "",
                                    "original":"20",

                                },
                                {
                                    "empty":"Customer Restroom Visits(Daily)",
                                    "modified":"",
                                    "original":"5",

                                },
                                {
                                    "empty":"Days Open per Week",
                                    "modified":"",
                                    "original":"5",

                                },
                                {
                                    "empty":"Number of Restrooms",
                                    "modified":"",
                                    "original":"2",
                                },
                                {
                                    "empty":"Number of Stalls",
                                    "modified":"",
                                    "original":"2",
                                },
                                {
                                    "empty":"Number of Urinals",
                                    "modified":"",
                                    "original":"2",
                                },
                                {
                                    "empty":"Delivery Frequency",
                                    "modified":"",
                                    "original":"Weekly Deliveries",
                                },
                                {
                                    "empty":"Billing Frequency",
                                    "modified":"",
                                    "original":"Monthly",
                                }
                               ],


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

Is there a way I can set each cell in the columns as its own field? and how would I add in a dropdown menu for the 2 cells within the column?

I am new to this so any additional information please let me know, thanks!

Adrew
  • 217
  • 1
  • 8
  • 25
  • check `cellTemplate` and construct multiple div elements. you can then customize the cell as you wish – Asqan Nov 04 '15 at 11:54
  • @Asqan I see how to apply a cellTemplate for the entire column as shown in my code above, but I am not sure how to do it for one cell. Should I set a celltemplate within the data[ ]? – Adrew Nov 04 '15 at 15:21
  • Look at [Format a ui-grid grid column as currency (RC 3.0)](http://stackoverflow.com/questions/27747184/format-a-ui-grid-grid-column-as-currency-rc-3-0) The field can take some flexible expressions. Otherwise I'd suggest the filter option. – Robert Cutajar Apr 11 '16 at 10:56

0 Answers0