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

[Bug Report][3.3.8] VDataTable - Boolean values are not shown in table #17810

Closed
ssierputowski11 opened this issue Jul 15, 2023 · 5 comments
Closed
Assignees
Labels
C: VDataTable VDatatable labs T: bug Functionality that does not work as intended/expected
Milestone

Comments

@ssierputowski11
Copy link

Environment

Vuetify Version: 3.3.8
Vue Version: 3.3.4
Browsers: Chrome 114.0.0.0
OS: Windows 10

Steps to reproduce

Create an array items for a v-data-table that has a boolean value and see that the boolean is blank in the table view.

Expected Behavior

expect to see true/false or some form of radio/checkbox or some way to view the boolean value in the table

Actual Behavior

Column with boolean value is blank all the way through

Reproduction Link

https://play.vuetifyjs.com/#...

@websitevirtuoso
Copy link
Contributor

Yes this is correct behaviour. because component recognize only strings.
Let's say you passed date object. but it will display as a string.

IN this case to display boolean just contert to string. This is not a bug

@websitevirtuoso
Copy link
Contributor

        iron: true.toString(),

@ssierputowski11
Copy link
Author

Yes this is correct behaviour. because component recognize only strings. Let's say you passed date object. but it will display as a string.

IN this case to display boolean just contert to string. This is not a bug

I'm not certain about the date example but similarly with an int/number object it displays just fine in the table. Why is that? Why can't that happen for boolean values?

@websitevirtuoso
Copy link
Contributor

if you want to get more details and how works code you can open source code and check.

@rti-Austin
Copy link

Currently, nothing displays for boolean values... so this does kind of seem like a bug (not just a feature request).

From past responses to this issue, it appears the intent is to have custom icons displayed for boolean values, which is awesome! However, it requires multiple, custom templates... one for each boolean property/column. For example:

Workaround 1: Custom Templates Per Property/Column

<template v-slot:item.prop1="{ item }">
  <v-icon v-if="item.raw.prop1 === true"> mdi-check-circle </v-icon>
</template>
<template v-slot:item.prop2="{ item }">
  <v-icon v-if="item.raw.prop2 === true"> mdi-check-circle </v-icon>
</template>
...

Workaround 2: Convert Boolean Values to String Values
The previously suggested workaround of manually converting boolean types to string can definitely work, but it could lead to downstream problems with logic expecting the original type (i.e. the string "false" is truthy). The value would likely need to be converted back to the original type before using the data. Additionally, it still requires custom templates for each property/column in order to display custom icons, defeating what seems to be the original intent.

Possible Enhancement:
What would be nice is if we could specify a default template by property type (not just by property name), such as boolean. For example, the following uses a new slot for items of type boolean (v-slot:itemType.boolean):

<template v-slot:itemType.boolean="{ itemValue }">
   <v-icon v-if="itemValue === true"> mdi-check-circle </v-icon>
</template>

This approach could provide an internal mechanism to display a value for boolean properties by default... and also allow them to be customized.

@KaelWD KaelWD added T: bug Functionality that does not work as intended/expected C: VDataTable VDatatable labs labels Sep 25, 2023
@KaelWD KaelWD self-assigned this Sep 25, 2023
@KaelWD KaelWD added this to the v3.3.x milestone Sep 25, 2023
@KaelWD KaelWD closed this as completed in 3759243 Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VDataTable VDatatable labs T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

No branches or pull requests

4 participants