Programing

좋은 테이블에서 선택한 행의 데이터를 가져오다.

c10106 2022. 4. 12. 18:42
반응형

좋은 테이블에서 선택한 행의 데이터를 가져오다.

얘들아, 나 처음이라 어떻게 해야 할지 모르겠는데 여기서 현재 선택된 행의 데이터를 어떻게 얻을 수 있는지 코드야.

       <div class="table-responsive-sm">
                     <vue-good-table
                     title="Page List"
                     :columns="columns1"
                     :rows="rows1"  
                     :paginationOptions="{enabled: false}">
                      
                       <template slot="table-row-after" slot-scope="props" >
                          <td class="fancy"><input type="checkbox" v-model="checkview[props.row.originalIndex]">
                           </td>
                          <td class="has-text-right"><input type="checkbox" v-model="checkedit[props.row.originalIndex]"></td>
                          <td class="has-text-right"><input type="checkbox" v-model="checkupate[props.row.originalIndex]"></td>
                          <td class="has-text-right"><input type="checkbox" v-model="checkdelete[props.row.originalIndex]"></td>
                       </template>
                  </vue-good-table>
      columns1: [
    {
      label: 'Page Name',
      field: 'pagename',
       sortable: false,
    },
     {
      label: 'View',
       sortable: false,
    },
     {
      label: 'edit',
       sortable: false,
    },
    {
      label: 'update',
      sortable: false,
    },
     {
      label: 'delete',
      sortable: false,
    },

  ],
   rows1:[],
 methods:{
               getTotals1(){
            var self = this;
            this.$http.get('http://localhost:3000/api/permissionpgs')
            .then(function (response) {
              console.log(response.data)
                 self.rows1 = response.data;      
            })
        },
 }

저장 방법이 트리거될 때 값진 데이터를 가져올 수 있는 방법이 있는지 확인하십시오.마지막으로 이것은 좋은 테이블이다.

체크된 항목의 값을 3개의 다른 객체에 저장한다. checkedit,checkupdate그리고checkdelete사용자가 테이블에서 확인란을 확인/선택 취소하는 경우이러한 물체는 다음과 같은 형태를 가질 것이다.

checkupdate{
  2: true, // index of the row: whether checked or unchecked
  5: false,
  20: true
}
now to get the rows for each of these objects all you have to do is loop through the object properties, collect the index that has value as true. then do this.rows1[index] to get the actual row object.

참조.URL: https://stackoverflow.com/questions/49704156/get-data-of-slected-row-in-vue-good-table

반응형