1

Am using core ui template in my angular project with boostrap 4 page

<div class="animated fadeIn">
    <div class="row">
        <div class="col-sm-12">
            <div class="card">
                <div class="card-header">
                    <button type="button" class="btn btn-sm mr-1 btn-success" data-toggle="modal"
                        routerLink="/branch/branch-edit">Create New</button>
                </div>
           
                <div class="card-body">
                    <div class="row">
                        <div class="col-sm-9">
                            <div class="form-group row" id="grid-container">
                                <angular-slickgrid gridId="branchGrid" [columnDefinitions]="columnDefinitions"
                                    [gridOptions]="gridOptions" [dataset]="dataset"
                                    (onAngularGridCreated)="angularGridReady($event)">
                                </angular-slickgrid>
                            </div>
                 </div>
            </div>
        </div>
    </div>
</div>

when i click navigation toggler grid is showing like this.

Please let me grid is showing outside of card..Pls let me know what did wrong

enter image description here

EDIT: After suggestion my grid like below..For bank filer option is overlapped with grid menu button..Pls suggest

[![enter image description here][4]][4]

EDIT below is my Ts.file

import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

import { AngularGridInstance, Column, GridOption, GraphqlService, GraphqlPaginatedResult, Filters, Formatters, OnEventArgs, FieldType } from 'angular-slickgrid';

import { BankDataService } from 'src/app/core/services/bank-data.service';
import { PageService } from 'src/app/core/services/page.service';


const GRAPHQL_QUERY_DATASET_NAME = 'banks';


@Component({
  templateUrl: './bank-list.component.html',
  styleUrls: ['./bank-list.component.scss']
})
export class BankListComponent implements OnInit {
  angularGrid: AngularGridInstance;
  columnDefinitions: Column[];
  gridOptions: GridOption;
  dataset = [];

  constructor(private dataService: BankDataService, private router: Router, private pageService: PageService) {
  
  }

  ngOnInit(): void {
    this.columnDefinitions = [
      {
        id: 'edit',
        field: 'id',
        excludeFromColumnPicker: true,
        excludeFromGridMenu: true,
        excludeFromHeaderMenu: true,
        formatter: Formatters.editIcon,
        minWidth: 30,
        maxWidth: 30,
        onCellClick: (e: Event, args: OnEventArgs) => {
          this.router.navigate(['/bank/bank-detail/' + args.dataContext.id]);
        }
      },
      { id: 'id', field: 'id', name: 'Id', filterable: true, sortable: true, maxWidth: 200, type: FieldType.number, filter: { model: Filters.inputNumber } },
      { id: 'name', field: 'name', name: 'Name', filterable: true, sortable: true , maxWidth: 200}
     ];

    this.gridOptions = {
      backendServiceApi: {
        service: new GraphqlService(),
        options: {
          columnDefinitions: this.columnDefinitions,
          datasetName: GRAPHQL_QUERY_DATASET_NAME
        },
        process: (query) => this.getBanks(),
      }
    };
 
  }

  angularGridReady(angularGrid: AngularGridInstance) {
    this.angularGrid = angularGrid;
  }

  getBanks(): Observable<GraphqlPaginatedResult> {

   
    var args = this.pageService.getPageArgs(this.angularGrid);
    console.log(args);
    return this.dataService.searchBanks(args)
      .pipe(map(
        page => {
          var result: GraphqlPaginatedResult = {
            data: {
              [GRAPHQL_QUERY_DATASET_NAME]: {
                nodes: page.items,
               
                totalCount: page.totalCount
              }
            }
          };

          return result;
        }));
  }
 
}

Where i have to call this.angularGrid.resizerService.resizeGrid();?

EDIT:I i set below

**

AngularSlickgridModule.forRoot({
      enableAutoResize: true,
      autoHeight: true,
      alwaysShowVerticalScroll: false,
      autoResize: {
        containerId: 'grid-container',
         sidePadding: 15,
        bottomPadding: 20,
        calculateAvailableSizeBy: 'container' ,
        -----------   if i set below the grid is showing correctly
        maxHeight: 600,   
        minHeight: 250,
        maxWidth: 800,
        minWidth: 200
-----------------
      },

** It is showing like this

enter image description here

Glen
  • 321
  • 4
  • 15
  • 1
    I think your problem come from `
    ` try to change to lower width `
    ` or if not really good, then try with `flex` [https://www.w3schools.com/cssref/css3_pr_justify-content.asp](https://www.w3schools.com/cssref/css3_pr_justify-content.asp)
    – B.S. Dec 25 '20 at 12:23
  • @B.S. somewhat it works..i have updated in the question..Can u pls suggest – Glen Dec 26 '20 at 04:26
  • 1
    You seem to be relying on angular-slickgrid to always resize perfectly but it's not perfect for multiple reasons, one of which is that the resizer tries to calculate the available size but DOM elements don't always provide that type on info (a div might show as 0px height and that can throw off the resizer), in your case you might want to read this angular-slickgrid [issue[(https://github.com/ghiscoding/Angular-Slickgrid/issues/175) – ghiscoding Dec 26 '20 at 05:25
  • You should seriously read through all the Wikis, read the [Auto-Resize Wiki](https://github.com/ghiscoding/Angular-Slickgrid/wiki/Grid-Auto-Resize), I can't help you more than that. – ghiscoding Dec 29 '20 at 06:01
  • sory...actully i am new to agular . from .2 days i am reading .but i coulld not make it – Glen Dec 29 '20 at 06:04
  • you shouldn't put that kind of configuration in the `forRoot` because that config is global and will be applied to all grids, so it's not a good idea to use in your case. You should move the `autoResize` config within that child grid. And for the `resizerService.resizeGrid();` well you can call that at any time, that will try to resize with what the available space, it probably doesn't work in your case because it can't find the correct space and I said it earlier, it could caused by many reasons. The best way to get someone to help you would be to provide a starblitz to test the code – ghiscoding Dec 30 '20 at 05:34
  • I actually don't think it's a good idea to use a Bootstrap Card, typically a Card is meant to display much smaller content, why don't you use just grid containers? I've done a project that was using `col-sm-12` with full width and when user showed a sidebar then I was changing the grid to `col-sm-7` and the sidebar to `col-sm-5` and calling the `resizerService.resizeGrid();` and it was working fine. I even had a grid in the sidebar sometimes, so I had a big grid in the main container and another grid in the sidebar. Just give it a try without a BS Card – ghiscoding Dec 30 '20 at 05:41
  • Ok..thank..I will try – Glen Dec 30 '20 at 06:53

1 Answers1

2

The problem is the amount of content in your row that exceed the width of the containing parent element. You see it because overflow is visible. The input elements all have a set width and are overflowing the container.

There is nothing wrong with the code. You just don't have the space you're asking for.

You could reduce the minwidth and maxwidth of id to something like 5 or 10.

All the fields displaying numbers could be smaller. Maybe you can save some space there. The phone number probably doesn't need a 30 characters long field.

You could also make the content small by using a smaller size.

Add a css class to your css file:

.make-smaller input{
font-size:10px;    // make the font small
width:fit-content; // will make is as big as the content
}

If this is still not enough your can make you content scrollable:

.make-scrollable{
overflow-x: scroll;    // make the container scrollable

}

Then you can use these css class in your html to apply them to your elements:

<div class="card-body make-scrolable">  <--- content scrolable 

    <div class="form-group row make-smaller" id="grid-container"> <-- make things smaller

      <angular-slickgrid gridId="branchGrid" 
        [columnDefinitions]="columnDefinitions"
        [gridOptions]="gridOptions" [dataset]="dataset"                                
        (onAngularGridCreated)="angularGridReady($event)">
      </angular-slickgrid>
     </div>
Daniel Geyfman
  • 246
  • 1
  • 10
MadeInDreams
  • 1,991
  • 5
  • 33
  • 64
  • yes..i have already know set maxwidth it is working fine..But is there any alternative solution without set maxwidth? i i have edited the qestion.. – Glen Dec 29 '20 at 07:30
  • If you would like to have more content then you can contain you might want to consider enabling scrolling? Are you trying to include the empty space on the right to have more room? @Glen – MadeInDreams Dec 29 '20 at 09:25
  • How to enable scrolling ? actully i have limited knowlege in css/javascipt.my problem i .if i not set max width and when i click toggler on top (right side) grid is overlapping ( 1st screen shot in qtn) – Glen Dec 29 '20 at 11:16