akveo / ng2-smart-table

Angular Smart Data Table component
https://akveo.github.io/ng2-smart-table/
MIT License
1.63k stars 878 forks source link

Table works, but without style #504

Open zezke opened 6 years ago

zezke commented 6 years ago

I am quite a rookie with Angular. I was under the impression that using ng2-smart-table would automatically apply the included CSS style. However it does not, the page is rather dull without any table borders. I am missing something? Should I include some version of Twitter Bootstrap?

piotrgolawski commented 6 years ago

Same here, tired.

AkhilNaidu09 commented 6 years ago

Even i faced same issue. But I have added external css using (/deep/).

mfsi-surajs commented 6 years ago

Did you find any solution ?

Xstoudi commented 6 years ago

Up!

zezke commented 6 years ago

@mfsi-surajs I did not, just using it "as is" for the time being.

mfsi-surajs commented 6 years ago

@zezke Got a temporary workaround, paste below style in your css or scss file

$table-font-color: #606c71;
$table-border-color: #e9ebec;

:host{
  /deep/ {

    table{
      color: $table-font-color;
      tr {
        td,th{
          border: 1px solid $table-border-color;
        }
      }
    }
  }
}  
SajithSUA commented 6 years ago

please give right ansers

ankypant commented 6 years ago

use below configuration in the settings object

attr: {
        class: 'table table-bordered'
      },

and

 :host /deep/ ng2-smart-table { 
    font-size: 16px; 
}

Example :

settings = {
  columns: {
    id: {
      title: 'ID'
    },
    name: {
      title: 'Full Name'
    },
    username: {
      title: 'User Name'
    },
    email: {
      title: 'Email'
    }
  },
attr: {
        class: 'table table-bordered'
      }
};
ovidiubarbu commented 6 years ago

I struggled a bit with this too. I was getting no grid and was quite annoying. Here what worked for me. I have added this into the css file for my component. I hope this helps:

:host /deep/ ng2-smart-table table{
    border-style: inset;
    border-color: initial;
    border-image: initial;
    border-width: 2px;

    display: table;
    border-spacing: 2px;
    border-color: grey; /* border of the big table*/

/* grid lines */
:host /deep/ ng2-smart-table table > tbody > tr > td {
    box-sizing: border-box;
    border: 1px solid grey;
}

/* headers grid color*/
:host /deep/ ng2-smart-table thead > tr > th  { 
    border: 1px solid grey;
    background-color:#673ab7;
}  
/*font size*/
:host /deep/ ng2-smart-table {
    font-size:16px;
}
alejandrotamayo commented 5 years ago

use below configuration in the settings object

attr: {
        class: 'table table-bordered'
      },

and

 :host /deep/ ng2-smart-table { 
    font-size: 16px; 
}

Example :

settings = {
  columns: {
    id: {
      title: 'ID'
    },
    name: {
      title: 'Full Name'
    },
    username: {
      title: 'User Name'
    },
    email: {
      title: 'Email'
    }
  },
attr: {
        class: 'table table-bordered'
      }
};

It worked for me. Thanks!!!

lorranpalmeira commented 5 years ago

I need to change color of table-bordered, i tried border-color ... doesn´t work. Any Ideia?

ajlg-vzla commented 5 years ago

What if i wanted the default style? i mean, the one showing when you install a full ngx-admin? thank you!

nvmnghia commented 4 years ago

What if i wanted the default style? i mean, the one showing when you install a full ngx-admin? thank you!

Did you find a way to use it with ngx-admin? I did install ngx-admin, then I somehow have to install ng2-smart-table separately, and now it is ugly as hell, not the gorgeous, corner-rounded one shown in the demo.

SashaSkywalker commented 4 years ago

Hi @nvmnghia ngx-admin uses @nebular/theme package, if you install that package and follow installation instruction (https://akveo.github.io/nebular/docs/guides/install-nebular#manually) then smart table will look like in ngx-admin.

nvmnghia commented 4 years ago

Hi @nvmnghia ngx-admin uses @nebular/theme package, if you install that package and follow installation instruction (https://akveo.github.io/nebular/docs/guides/install-nebular#manually) then smart table will look like in ngx-admin.

Hi, Thanks for the quick support. I did install Nebular manually like by following that guide, and the problem is still there. Can you help me fix this? This is the smart table right now:

12

Edit: I saw the screenshot attached in the smart table page, and indeed the component works :) just not the way in the Nebular page.

SashaSkywalker commented 4 years ago

You are right, some steps in the nebular setup instruction are missed. Have a look at demo, this is working example of smart tables with nebular.

smart table page example just add some basic styles to table

table {
  display: block;
  width: 100%;
  overflow: auto;
  word-break: normal;
  word-break: keep-all;
}

table th {
  font-weight: bold;
}

table th, table td {
  padding: 0.5rem 1rem;
  border: 1px solid #e9ebec;
}

table tr.section {
  font-size: .75rem;
  font-weight: bold;
}
nvmnghia commented 4 years ago

@SashaSkywalker Please update it. Also, what are the purposes of @theme and @core folder? I have to manually copy them to use ThemeModule

import { ThemeModule } from '../../@theme/theme.module';

And now I lost the icons :v. The reason why I got text instead of icons in the previous reply was that I didn't notice the <i>s were manually added in the settings.

13

I will try your method in the next hour.

nvmnghia commented 4 years ago

I think some CSS is not loaded in my case. When I paste the CSS <link> from the demo site to my page, things eventually look good.

nvmnghia commented 4 years ago

I fixed my issue. I installed some missing styles package in angular.json. Did I do something wrong in my installation? I just follow the guide in the main page, and it should have installed all styles for me in the first place.

Styles I installed:

"styles": [
    "./node_modules/bootstrap/dist/css/bootstrap.css",
    "./node_modules/typeface-exo/index.css",
    "./node_modules/roboto-fontface/css/roboto/roboto-fontface.css",
    "./node_modules/@fortawesome/fontawesome-free/css/all.css",
    "./node_modules/socicon/css/socicon.css",
    "./node_modules/nebular-icons/scss/nebular-icons.scss",
    "./node_modules/angular-tree-component/dist/angular-tree-component.css",
    "./node_modules/pace-js/templates/pace-theme-flash.tmpl.css",
    "./node_modules/leaflet/dist/leaflet.css",
]
Ajinkyadon commented 4 years ago

table{ color: $table-font-color; tr { td,th{ border: 1px solid $table-border-color; } } }

Hey man thanks

Mustapha-HajRomdhane commented 4 years ago

to edit table you can use : :host /deep/ ng2-smart-table table{ border-collapse:separate !important; border-spacing:0.3125rem 0.3125rem !important; }

you can edit td too using : :host /deep/ ng2-smart-table tbody > tr:first-child > td:nth-child(2) { color: white;

background-color: #4472C4 !important;
width: 200px !important;
background-image: url("assets/img/icons8-chargement-en-cours-32.png") !important;
background-position: 5% 50% !important; /* Center the image */

background-repeat: no-repeat !important; / Do not repeat the image /

}