2

I am using nggrid for my data representation and one of the column holds address which is sometimes multiline and long. I want my row to be multiline with size depending on number of lines address is distributed in. How can I have an editable row. I am using nggrid 2.012

"devDependencies": {
    "ng-grid": "~2.0.12"
}

I have paging implemented

$scope.gridOptions = {
    data: 'myData',
    enablePaging: true,
    showFooter: true,
    totalServerItems: 'totalServerItems',
    pagingOptions: $scope.pagingOptions,
    filterOptions: $scope.filterOptions,
    plugins: [new ngGridFlexibleHeightPlugin()],
    columnDefs: [{field:'client_order_id', displayName:'Order Id'}, {field:'customer_name',displayName:'Customer Name'},
        {field:'customer_phone', displayName:'Phone Number'},{field:'address', displayName:'Address'}]
};

Following is my current view

<section data-ng-controller="OrdersController" data-ng-init="find()">
  <div class="page-header">
    <h1>Orders</h1>
  </div>

  <div class="gridStyle" ng-grid="gridOptions"/></div>

</section>

Want to also have multiline addresses

raju
  • 4,788
  • 15
  • 64
  • 119

3 Answers3

2

another common way is to show tooltip with whole long text when mouse hovering on the cell:

columnDefs: [
    {
        field:'address',
        displayName:'Address',
        cellTemplate: '<div class="ngCellText" ng-class="col.colIndex()"><span ng-cell-text title="{{COL_FIELD}}">{{COL_FIELD}}</span></div>'
    }
]
hjl
  • 2,794
  • 3
  • 18
  • 26
0

you can not have variable rowHeight because ngGrid uses the fixed rowHeight to do virtual scrolling.

you will need to hack into ngGrid style to fix this

follow this way to make a scrollbar in cell to view the whole address

columnDefs: [
    {
        field:'address',
        displayName:'Address',
    }
]

overwrite ngGrid style in your own style :

.ngCellText {
    overflow: auto;
    text-overflow: auto;
}
hjl
  • 2,794
  • 3
  • 18
  • 26
0

You can change the row height by setting 'rowHeight' property.

columnDefs: [{
        field:'address',
        displayName:'Address',
        rowHeight: 60,
        cellClass: 'wrap-text'
    }
]

You can use it with a custom template to show a tooltip as suggested earlier.

Use it with a custom css class.

.wrap-text {
    white-space: normal;
}
Aman Mahajan
  • 1,293
  • 14
  • 14