Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!--
  Forked from:
  https://quasar.dev/vue-components/table#Example--Basic
-->
<div id="q-app">
  <div class="q-pa-md">
    <div class="row q-col-gutter-sm">
      <div class="col">
        <q-table
          title="Simple"
          :data="data"
          :columns="columns"
          row-key="name"
          dense
        >
          <template v-slot:body-cell-actions="props">
            <q-td :props="props">
              <q-btn dense round flat color="grey" @click="editRow(props)" icon="edit"></q-btn>
              <q-btn dense round flat color="grey" @click="deleteRow(props)" icon="delete"></q-btn>
            </q-td>          
          </template>
        </q-table>
      </div>
      <div class="col">
        <q-table
          flat
          bordered
          class="statement-table"
          title="Complex"
          :data="currencyData"
          :hide-header="mode === 'grid'"
          :columns="currencyColumns"
          row-key="__index"
          :grid="mode == 'grid'"
          :filter="filter"
          virtual-scroll
          :pagination.sync="pagination"
          :rows-per-page-options="[0]"
        >
          <template v-slot:top-right="props">
            <q-input
              outlined
              dense
              debounce="300"
              v-model="filter"
              placeholder="Search"
            >
              <template v-slot:append>
                <q-icon name="search" />
              </template>
            </q-input>

            <q-btn
              flat
              round
              dense
              :icon="props.inFullscreen ? 'fullscreen_exit' : 'fullscreen'"
              @click="setFs(props)"
            >
              <q-tooltip :disable="$q.platform.is.mobile" v-close-popup>{{
                props.inFullscreen ? "Exit Fullscreen" : "Toggle Fullscreen"
              }}</q-tooltip>
            </q-btn>

            <q-btn
              flat
              round
              dense
              :icon="mode === 'grid' ? 'list' : 'grid_on'"
              @click="mode = mode === 'grid' ? 'list' : 'grid'"
            >
              <q-tooltip :disable="$q.platform.is.mobile" v-close-popup>{{mode === "grid" ? "List" : "Grid"}}</q-tooltip>
            </q-btn>
            <div class="q-pa-sm q-gutter-sm">
              
            </div>
          </template>
          
          <template #body-cell-status="props">
            <q-td :props="props">
                <q-chip
                  :color="props.row.status == 'Active' ? 'green': props.row.status == 'Disable' ? 'red': 'grey'"
                  text-color="white"
                  dense
                  class="text-weight-bolder"
                  square
                >{{props.row[props.col.name]}}</q-chip>
            </q-td>
          </template>
          <template #body-cell-action="props">
            <q-td>
              <q-btn dense flat round color="blue" field="edit" icon="edit" @click="editItem(props.row)"></q-btn>
              </q-td>
          </template>
          
<!--           <template v-slot:bottom>
            <div class="pagination-total q-mt-sm flex flex-center">
              <div class="text-medium-regular">
                Total {{ currencyData.length }}
                <span v-if="totalRecord > 1">results</span>
                <span v-else>result</span>
              </div>
            </div>
            <div class="pagination-container q-my-sm flex flex-center">
              <q-pagination
                v-model="page"
                color="secondary"
                :input="true"
                :max="pageCount"
                :max-pages="6"
                @input="fetchData(false)"
                :boundary-numbers="true"
              />
            </div>
          </template> -->

          <template v-slot:item="props">
            <div
              class="q-pa-xs col-xs-12 col-sm-6 col-md-4 col-lg-3 grid-style-transition"
              :style="props.selected ? 'transform: scale(0.95);' : ''"
            >
              <q-card :class="props.selected ? 'bg-grey-2' : ''">
    <!--             <q-card-section>
                  <q-checkbox dense v-model="props.selected" :label="props.row.name"></q-checkbox>
                  {{props.row.name}}
                </q-card-section>
                <q-separator></q-separator> -->
                <q-list dense>
                  <q-item v-for="col in props.cols" :key="col.name">
                    <q-item-section>
                      <q-item-label>{{ col.label }}</q-item-label>
                    </q-item-section>
                    <q-item-section side>
                      <q-chip v-if="col.name === 'status'"
                        :color="props.row.status == 'Active' ? 'green': props.row.status == 'Disable' ? 'red': 'grey'"
                        text-color="white"
                        dense
                        class="text-weight-bolder"
                        square
                      >{{col.value}}</q-chip>
                      <q-btn v-else-if="col.name === 'action'" dense flat color="primary" field="edit" icon="edit" @click="editItem(props.row)" ></q-btn>
                      <q-item-label v-else caption :class="col.classes ? col.classes : ''">{{ col.value }}</q-item-label>
                    </q-item-section>
                  </q-item>
                </q-list>
              </q-card>
            </div>
          </template>
        </q-table>
      </div>
    </div>
    <q-dialog v-model="show_dialog">
                <q-card style="width: 600px; max-width: 60vw">
                  <q-card-section>
                    <q-btn round flat dense icon="close" class="float-right" color="grey-8" v-close-popup></q-btn>
                    <div class="text-h6">Update Item</div>
                  </q-card-section>
                  <q-separator inset></q-separator>
                  <q-card-section class="q-pt-none">
                    <q-form class="q-gutter-md">
                      <q-list>
                        <q-item>
                          <q-item-section>
                            <q-item-label class="q-pb-xs">Currency Name</q-item-label>
                            <q-input dense outlined v-model="editedItem.name" />
                          </q-item-section>
                        </q-item>
                        <q-item>
                          <q-item-section>
                            <q-item-label class="q-pb-xs">Code</q-item-label>
                            <q-input dense outlined v-model="editedItem.code" />
                          </q-item-section>
                        </q-item>
                        <q-item>
                          <q-item-section>
                            <q-item-label class="q-pb-xs">Buy</q-item-label>
                            <q-input dense outlined v-model="editedItem.buyRate" />
                          </q-item-section>
                        </q-item>
                        <q-item>
                          <q-item-section>
                            <q-item-label class="q-pb-xs">Spot</q-item-label>
                            <q-input dense outlined v-model="editedItem.spotRate" />
                          </q-item-section>
                        </q-item>
                        <q-item>
                          <q-item-section>
                            <q-item-label class="q-pb-xs">Sell</q-item-label>
                            <q-input dense outlined v-model="editedItem.sellRate" />
                          </q-item-section>
                        </q-item>
                        <q-item>
                          <q-item-section>
                            <q-item-label class="q-pb-xs">Symbol</q-item-label>
                            <q-input dense outlined v-model="editedItem.symbol" />
                          </q-item-section>
                        </q-item>
                        <q-item>
                          <q-item-section>
                            <q-item-label class="q-pb-xs">Status:Active/Disable</q-item-label>
                            <q-input dense outlined v-model="editedItem.status" />
                          </q-item-section>
                        </q-item>
                      </q-list>
                    </q-form>
                  </q-card-section>
                  <q-card-section>
                    <q-card-actions align="right">
                      <q-btn
                        flat
                        label="Cancel"
                        color="warning"
                        dense
                        v-close-popup
                      ></q-btn>
                      <q-btn
                        flat
                        label="OK"
                        color="primary"
                        dense
                        v-close-popup
                        @click="updateRow"
                      ></q-btn>
                    </q-card-actions>
                  </q-card-section>
                </q-card>
              </q-dialog>
  </div>
</div>
              
            
!

CSS

              
                
              
            
!

JS

              
                const defaultItem = {
        name: '',
        code: '',
        buyRate: '',
        spotRate: '',
        sellRate: '',
        symbol: '',
        status: ''
      }

const currencyColumns = [
        {
          name: "name",
          align: "left",
          label: "Currency Name",
          field: "name",
          sortable: true
        },
        {
          name: "buyRate",
          align: "center",
          label: "Buy Rate",
          field: "buyRate",
          sortable: true,
          classes: 'text-green'
        },
        {
          name: "sellRate",
          align: "left",
          label: "Sell Rate",
          field: "sellRate",
          sortable: true,
          classes: 'text-red'
        },
        {
          name: "symbol",
          align: "center",
          labelalign: "left",
          label: "Symbol",
          field: "symbol",
          sortable: true
        },
        {
          name: "status",
          align: "center",
          label: "Status",
          field: "status",
          sortable: true
        },
        {
          name: "action",
          align: "right",
          label: "Action",
          field: "action"
        }
      ]

const currencies = [
        {
          name: "Malaysian Rinngit",
          code: "MYR",
          buyRate: "4.097(-2.5%)",
          spotRate: "4.19",
          sellRate: "4.238(+0.5%)",
          symbol: "RM",
          status: "Active"
        },
        {
          name: "Singapore Dollar",
          code: "SGD",
          buyRate: "xxxx(-2.5%)",
          spotRate: "x.xx",
          sellRate: "x.xxx(+0.5%)",
          symbol: "$",
          status: "Active"
        },
        {
          name: "Chinese Yuan",
          code: "CNY",
          buyRate: "xxxx(-2.5%)",
          spotRate: "x.xx",
          sellRate: "x.xxx(+0.5%)",
          symbol: "¥",
          status: "Active"
        },
        {
          name: "Malaysian Rinngit",
          code: "MYR",
          buyRate: "4.097(-2.5%)",
          spotRate: "4.19",
          sellRate: "4.238(+0.5%)",
          symbol: "RM",
          status: "Active"
        },
        {
          name: "Singapore Dollar",
          code: "SGD",
          buyRate: "xxxx(-2.5%)",
          spotRate: "x.xx",
          sellRate: "x.xxx(+0.5%)",
          symbol: "$",
          status: "Active"
        },
        {
          name: "Chinese Yuan",
          code: "CNY",
          buyRate: "xxxx(-2.5%)",
          spotRate: "x.xx",
          sellRate: "x.xxx(+0.5%)",
          symbol: "¥",
          status: "Active"
        }
      ]

new Vue({
  el: '#q-app',
  data () {
    return {
      inFs: false,
      columns: [
        {
          name: 'name',
          required: true,
          label: 'Dessert (100g serving)',
          align: 'left',
          field: row => row.name,
          format: val => `${val}`,
          sortable: true
        },
        { name: 'calcium', label: 'Calcium (%)', field: 'calcium', sortable: true, sort: (a, b) => parseInt(a, 10) - parseInt(b, 10) },
        { name: 'iron', label: 'Iron (%)', field: 'iron', sortable: true, sort: (a, b) => parseInt(a, 10) - parseInt(b, 10) },
        { name: 'actions', label: 'Actions', field: '', align:'center' },
      ],
      data: [
        {
          name: 'Frozen Yogurt',
          calories: 159,
          fat: 6.0,
          carbs: 24,
          protein: 4.0,
          sodium: 87,
          calcium: '14%',
          iron: '1%'
        },
        {
          name: 'Ice cream sandwich',
          calories: 237,
          fat: 9.0,
          carbs: 37,
          protein: 4.3,
          sodium: 129,
          calcium: '8%',
          iron: '1%'
        },
        {
          name: 'Eclair',
          calories: 262,
          fat: 16.0,
          carbs: 23,
          protein: 6.0,
          sodium: 337,
          calcium: '6%',
          iron: '7%'
        },
        {
          name: 'Cupcake',
          calories: 305,
          fat: 3.7,
          carbs: 67,
          protein: 4.3,
          sodium: 413,
          calcium: '3%',
          iron: '8%'
        },
        {
          name: 'Gingerbread',
          calories: 356,
          fat: 16.0,
          carbs: 49,
          protein: 3.9,
          sodium: 327,
          calcium: '7%',
          iron: '16%'
        },
        {
          name: 'Jelly bean',
          calories: 375,
          fat: 0.0,
          carbs: 94,
          protein: 0.0,
          sodium: 50,
          calcium: '0%',
          iron: '0%'
        },
        {
          name: 'Lollipop',
          calories: 392,
          fat: 0.2,
          carbs: 98,
          protein: 0,
          sodium: 38,
          calcium: '0%',
          iron: '2%'
        },
        {
          name: 'Honeycomb',
          calories: 408,
          fat: 3.2,
          carbs: 87,
          protein: 6.5,
          sodium: 562,
          calcium: '0%',
          iron: '45%'
        },
        {
          name: 'Donut',
          calories: 452,
          fat: 25.0,
          carbs: 51,
          protein: 4.9,
          sodium: 326,
          calcium: '2%',
          iron: '22%'
        },
        {
          name: 'KitKat',
          calories: 518,
          fat: 26.0,
          carbs: 65,
          protein: 7,
          sodium: 54,
          calcium: '12%',
          iron: '6%'
        }
      ],
      noti: () => {},
      show_dialog: false,
      editedIndex: -1,
      editedItem: defaultItem,
      filter: "",
      mode: "list",
      currencyColumns: currencyColumns,
      currencyData: currencies,
      pagination: {
        page: 1,
      },
      page: 1,
      totalRecord: 0,
      pageCount: 1,
    }
  },
  methods: {
    editRow(props) {
      this.noti()
      // do something
      this.noti = this.$q.notify({
        type: 'info',
        textColor: 'grey-10',
        multiLine: true,
        message: `I'll edit row data => ${JSON.stringify(props.row).split(',').join(', ')}`,
        timeout: 2000
      })
    },
    deleteRow(props){
      this.noti()
      // do something
      this.noti = this.$q.notify({
        type: 'negative',
        multiline: true,
        message: `I'll delete row data => ${JSON.stringify(props.row).split(',').join(', ')}`,
        timeout: 2000
      })
    },
    addRow() {
      if (this.editedIndex > -1) {
        Object.assign(this.currencyData[this.editedIndex], this.editedItem);
      } else {
        this.currencyData.push(this.editedItem);
      }
      this.close()
    },
    deleteItem(item) {
      const index = this.currencyData.indexOf(item);
      confirm("Are you sure you want to delete this item?") &&
        this.currencyData.splice(index, 1);
    },
    editItem(item) {
      this.editedIndex = this.currencyData.findIndex((v, i) =>v.__index === item.__index)
      this.editedItem = Object.assign({}, item);
      this.show_dialog = true;
    },
    close () {
      this.show_dialog = false
      setTimeout(() => {
        this.editedItem = defaultItem
        this.editedIndex = -1
      }, 300)
    },
    setFs(props){
      props.toggleFullscreen()
      this.inFs = props.inFullscreen
    },
    updateRow() {
      this.currencyData.splice(this.editedIndex, 1, this.editedItem)
      this.$q.notify({type:"positive", message: `Item '${this.editedItem.name}' updated.`, timeout: 500 })
    }
  },
  mounted() {
    // add indices
    this.currencyData = this.currencyData.map((v, i) => ({ ...v, __index: i}))
  }
})
              
            
!
999px

Console