Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column doesn't set column type according to data type #5032

Closed
chuckn0rris opened this issue Aug 9, 2022 · 0 comments
Closed

Column doesn't set column type according to data type #5032

chuckn0rris opened this issue Aug 9, 2022 · 0 comments
Assignees
Labels
bug Something isn't working forum Issues from forum resolved Fixed but not yet released (available in the nightly builds)
Milestone

Comments

@chuckn0rris
Copy link

Forum post

Filters do not work right for integer fields.

Testcase:

// Model class
class GroupModel extends Model {
  static get $name(): string {
    return 'GroupModel'
  }

  static get fields(): Partial<DataFieldConfig>[] {
    return [
      { name: 'teamId', type: 'int', dataSource: 'team_id' },
      { name: 'numPlayers', type: 'number', readOnly: true, persist: false },
    ]
  }
}

// Grid columns
const columns: Partial<ColumnConfig>[] = [
  {
    text: 'Groups',
    field: 'title',
    flex: 1,
  },
  {
    text: 'Team ID',
    field: 'teamId',
    width: 100,
    align: 'right',
  },
  {
    text: '#',
    field: 'numPlayers',
    width: 20,
    align: 'right',
  },
]

See result:
rendered good
Screen Shot 2022-08-08 at 02.05.23.png

Team ID header filter - OK
Screen Shot 2022-08-08 at 02.05.32.png

Team ID cell menu - NOT OK:
a. You can only apply "Equal" filter
b. Once you apply equal from cell menu, there is no value in header filter
Screen Shot 2022-08-08 at 02.05.41.png

_# header filter is OK
Screen Shot 2022-08-08 at 02.06.10.png

_# cell menu - OK: it has < > = filters and the value matches the header filter
Screen Shot 2022-08-08 at 02.06.42.png

The issue with filter can be worked around with filterType column config. For example:

const columns: Partial<ColumnConfig>[] = [
  ....
  {
    text: 'Team ID',
    field: 'teamId',
    width: 100,
    align: 'right',
    filterType: 'number', // This is the fix for int data field
  },
  ...
]

Team ID cell filter works
Screen Shot 2022-08-08 at 02.15.59.png

@chuckn0rris chuckn0rris added bug Something isn't working forum Issues from forum labels Aug 9, 2022
@matsbryntse matsbryntse self-assigned this Sep 11, 2022
@matsbryntse matsbryntse added ready for review Issue is fixed, the pull request is being reviewed resolved Fixed but not yet released (available in the nightly builds) and removed ready for review Issue is fixed, the pull request is being reviewed labels Sep 11, 2022
@matsbryntse matsbryntse added this to the 5.1.4 milestone Sep 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working forum Issues from forum resolved Fixed but not yet released (available in the nightly builds)
Projects
None yet
Development

No branches or pull requests

2 participants