Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is paging and columnResizing not working in ui-grid v3.0.0-rc.11

I can't seem to get any paging or column re-sizing working in the new ngGrid (ui-Grid) rc build v3.0.0-rc.11. It should be really straight forward according to this example: http://ui-grid.info/docs/#/tutorial/401_AllFeatures

For my main div, if I do this:

<div ui-grid="productGridOptions"  ui-grid-resize-columns class="uiGridProducts">

and in my controller do this:

$scope.productGridOptions={};       


         $scope.productGridOptions.enableColumnResizing = true;
         $scope.productGridOptions.enableFiltering = false;
         $scope.productGridOptions.enablePaging = true;

         $scope.productGridOptions.pagingOptions = {
                    pageSizes: [250, 500, 1000],
                    pageSize: 250,
                    currentPage: 1
         };


         $scope.productGridOptions.rowIdentity = function(row) {
            return row.id;
          };

         $scope.productGridOptions.getRowIdentity = function(row) {
            return row.id;
         };

         $scope.productGridOptions.data = 'products';

        //The options for the data table    
        $scope.productGridOptions.columnDefs = [
                  { name:'ID', field: 'id' },
                  { name:'Product', field: 'productName' },
                  { name:'Active Ing.', field: 'activeIngredients'},
                  { name:'Comments', field: 'comments' }
                ];

        prProductService.getProducts().then(function(products) {
            $scope.products = products;



        });

Neither paging or column resizing work. There are no paging examples on the ui-grid tutorial, so assume it is similar to ngGrid, but its column resizing which I really need at the moment.

Regards

i

like image 271
smackenzie Avatar asked Oct 03 '14 10:10

smackenzie


People also ask

Is UI grid free?

Generic UI Data Grid is one of the best free grid library. All of that makes this library a great free to use Angular data table component.

What is onRegisterApi in UI grid?

onRegisterApi is used to handle events. For example: If an edit is made, or a row is selected, you would use the onRegisterApi to catch the event and run some function. As for ordering, it doesn't matter if your gridOptions are created first, or the html DOM element.


3 Answers

Well for column resizing, thanks to this link

http://technpol.wordpress.com/2014/08/23/upgrading-to-ng-grid-3-0-ui-grid/

apparently you have to add 'ui.grid.resizeColumns' as a dependency into your app module, and just use the ui-grid-resize-columns tag in the div (as I am doing)...

I removed the code

 $scope.productGridOptions.enableColumnResizing = true;

And column resizing is working now....

Now on to paging.

Regards

i

like image 106
smackenzie Avatar answered Oct 14 '22 00:10

smackenzie


Column resizing is working well for me. I had to add to add 'ui.grid.resizeColumns' as a dependency:

angular.module('app', ['ngRoute', 'ngResource', 'ui.bootstrap', 'ui.grid', 'ui.grid.resizeColumns'])

Then in your html you add the ui-grid-resize-columns class:

<div class="grid" ui-grid="gridOptions" ui-grid-resize-columns></div>

And finally in your controller you set enableColumnResizing to true in gridOptions:

$scope.gridOptions = {
    data: 'data.data',
    enableSorting: true,
    enableColumnResizing: true
}

Hope that it finally works for you.

Extra info at: angular-ui-grid column resizing

like image 43
tebanep Avatar answered Oct 14 '22 02:10

tebanep


I can't speak for earlier versions, but in ui-grid version 3.1.1 it is sufficient to add the ui.grid.resizeColumns dependency to your module and set enableColumnResizing = true in gridOptions. It's not necessary to add the ui-grid-resize-columns attribute to the div tag.

like image 2
Kirby Avatar answered Oct 14 '22 00:10

Kirby