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

    Datatable with checkbox

    Help
    2
    4
    3021
    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.
    • E
      EfSantos last edited by

      I have the following code:

      <template>
        <div>
          <div class="layout-padding">
            <q-data-table
              :data="organizacoesApoiadas.content"
              :config="configs"
              :columns="columns">
      
              <template slot="col-selecione" scope="cell">
                  <q-checkbox :value="cell.row.check" @input="preencheVariavel(cell.row)"></q-checkbox>
              </template>
            </q-data-table>
      
            <q-pagination
              v-model="paginaAtual"
              :max="organizacoesApoiadas.totalPages || 1"
              @input="getOrganizacoesApoiadas"></q-pagination>
            <button class="primary pull-right" @click="atualizar()">autorizar</button>
          </div>
        </div>
      </template>
      
      #JS
      <script>
        export default {
          name: 'OrganizacoesApoiadas',
          mounted () {
            this.getOrganizacoesApoiadas()
          },
          data () {
            return {
              cods: [],
              paginaAtual: 1,
              qtdPorPagina: 10,
              organizacoesApoiadas: { content: [] },
              configs: {
                rowHeight: '50px',
                messages: {
                  noData: '<i class="text-red">Atenção: </i> Nenhuma organização encontrada!'
                }/* ,
                selection: 'multiple' */
              },
              columns: [
               // { label: 'Codigo', field: 'cdOrg', width: '60px' },
                { label: '', field: 'selecione', width: '100px', filter: true },
                { label: 'Nome da organização', field: 'nmOrg', width: '100px', filter: true },
                { label: 'Sigla da organização', field: 'sgOrg', width: '50px', filter: true }
              ]
            }
          },
          methods: {
            getOrganizacoesApoiadas () {
              this.boletimAPI()
              .buscarOrganizacoesApoiadas(this.paginaAtual, this.qtdPorPagina)
              .then(response => { this.organizacoesApoiadas = response.data })
            },
            preencheVariavel (data) {
              this.cods.push(data.cdOrg)
              console.log(this.props)
            },
            autorizar (data) {
              console.log(data)
            }
          }
        }
      </script>
      

      The problem is: The checkbox is not becaming checked when clicked. What am I doing wrong?

      Btw, I’m using v0.13

      1 Reply Last reply Reply Quote 0
      • L
        leon last edited by leon

        Hi.
        You can use Vue ref and get the att selectedRows

        computed: {
              listaSelecionada () {
                return this.$refs.table.selectedRows.map((organizacao) => { return organizacao.data.cdOrg })
              }
            }
        1 Reply Last reply Reply Quote 0
        • L
          leon last edited by

          v-model whit boolean is mandatory to check box works.

          1 Reply Last reply Reply Quote 0
          • L
            leon last edited by

            I have another solution https://codesandbox.io/s/zrmmq55nxl

            Dont know how to make the $q.theme work, so the checbox are not showing the icons.
            Btw it works.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post