No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    q-table with reactive i18n translations for columns name

    Framework
    ith this code
    2
    3
    1180
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Castris
      Castris last edited by

      I think I’m doing something wrong. The other day I asked but I did not understand well and did not locate the conversation.
      My app uses i18n and it works fine except in the column columns, which are not reactive to the language change.

      <template>
      ...
      <q-table
        :title="$t('users.label')"
        :data="filteredUsers"
        :columns="columns"
        table-header-class="bg-light-blue-1"
        row-key="email"
        :rows-per-page-label="$t('users.records')"
      >
      . . .
      <script>
      export default {
        name: 'UsersPage',
        components: { ListDomains },
        data () {
          return {
            tab: 'users'      columns: [
              {
                name: 'avatar',
                align: 'center',
                field: row => row.avatar,
                sortable: false
              },
              {
                name: 'email',
                required: true,
                label: this.$t('users.label'),
                align: 'left',
                field: row => row.email,
                format: val => `${val}`,
                sortable: true
              },
              {
                name: 'name',
                label: this.$t('users.name'),
                align: 'left',
                field: row => row.name,
                format: val => `${val}`,
                sortable: true
              },
              {
                name: 'active',
                align: 'center',
                label: this.$t('users.active'),
                field: row => row.active,
                format: val => String(!!val),
                sortable: true
              },
              {
                name: 'show',
                align: 'center',
                sortable: false
              },
              {
                name: 'edit',
                align: 'center',
                sortable: false
              },
              {
                name: 'archive',
                align: 'center',
                sortable: false
              },
              {
                name: 'delete',
                align: 'center',
                sortable: false
              }
            ]
          }
      ...
      

      With this code translation of columns only occours when enter in app with any language. But not after.

      1 Reply Last reply Reply Quote 0
      • C
        chyde90 last edited by

        Making columns a computed property should do the trick

        1 Reply Last reply Reply Quote 2
        • Castris
          Castris last edited by

          Thanks… Work fine after create a computed propìerty for columns

          columnsI18n () {
                let columns = [
                  {
                    name: 'domain',
                    required: true,
                    label: this.$t('domains.label'),
                    align: 'left',
                    field: row => row.domain,
                    format: val => `${val}`,
                    sortable: true
                  },
                  {
                    name: 'active',
                    align: 'center',
                    label: this.$t('domains.active'),
                    field: row => row.active,
                    format: val => String(!!val),
                    sortable: true
                  },
                  {
                    name: 'show',
                    align: 'center',
                    sortable: false
                  },
                  {
                    name: 'edit',
                    align: 'center',
                    sortable: false
                  },
                  {
                    name: 'archive',
                    align: 'center',
                    sortable: false
                  },
                  {
                    name: 'delete',
                    align: 'center',
                    sortable: false
                  }
                ]
                return columns
              }
          
          1 Reply Last reply Reply Quote 1
          • First post
            Last post