swimlane / ngx-datatable

✨ A feature-rich yet lightweight data-table crafted for Angular
http://swimlane.github.io/ngx-datatable/
MIT License
4.63k stars 1.68k forks source link

datatable-column not working as expected #346

Closed camberos closed 7 years ago

camberos commented 7 years ago
[X] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here

Current behavior At the moment I am trying to populate the data table from a GET result, the objects are ok, as shown in the image below.

screen shot 2016-12-06 at 12 47 25 pm

Once I add a third column with an underscore in the key, is where it gets ugly. As shown in the screenshot. For example the value group_id

screen shot 2016-12-06 at 1 00 09 pm

This is the output, showing the missing column.

screen shot 2016-12-06 at 12 52 10 pm

Expected behavior The expected behaviour should be as simple as shown in the code. Add a datatable-column with some basic parameters and should work, unless I am missing something in the configuration.

amcdnl commented 7 years ago

You need to use prop instead of name.

kuncevic commented 7 years ago

Just being caught by that having the underscore in the json prop. Why it is like that? @amcdnl could you provide some more details?

In my case I had just simple tamplate:

<ngx-datatable
      class="material expandable"
      [rows]="rows"
      [columnMode]="'force'"
      [columns]="columns"
      [headerHeight]="50"
      [footerHeight]="50"
      [rowHeight]="'auto'"
      [limit]="10"
      [selectionType]="'single'">
  </ngx-datatable>

and columns defined like that:

  columns = [
    { name: 'id' },
    { name: 'system_id' },  //has to use `prop` instead of `name` to make it display in the datatable
    { name: 'state' },
    { name: 'inactive' }
  ];