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--Pagination-slot
-->
<div id="q-app">
  <q-btn dense color="secondary" label="Add Row" @click="show_dialog = true" no-caps></q-btn>
  <div class="q-pa-md">
    <q-table
      flat
      bordered
      class="statement-table"
      title="Currency"
      :data="currencyData"
      :hide-header="mode === 'grid'"
      :columns="currencyColumns"
      row-key="name"
      :grid="mode == 'grid'"
      :filter="filter"
      virtual-scroll
      :pagination.sync="pagination"
    >
      <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="props.toggleFullscreen"
          v-if="mode === 'list'"
        >
          <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';
            separator = mode === 'grid' ? 'none' : 'horizontal';
          "
          v-if="!props.inFullscreen"
        >
          <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">
          <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_adjust</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_adjust</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-select dense outlined v-model="editedItem.status" :options="options"></q-select>
                      </q-item-section>
                    </q-item>
                  </q-list>
                </q-form>
              </q-card-section>
              <q-card-section>
                <q-card-actions align="right">
                  <q-btn
                    flat
                    label="OK"
                    color="blue"
                    dense
                    v-close-popup
                    @click="updateRow"
                  ></q-btn>
                  <q-btn
                    flat
                    label="Cancel"
                    color="blue"
                    dense
                    v-close-popup="cancelEnabled"
                  ></q-btn>
                </q-card-actions>
              </q-card-section>
            </q-card>
          </q-dialog>
        </div>
      </template>

      <template v-slot:body="props">
        <q-tr :props="props">
          <q-td key="name" :props="props">
            {{ props.row.name }}
          </q-td>
          <q-td key="code" :props="props">
            {{ props.row.code }}
          </q-td>
          <q-td key="buyRate" :props="props" class="text-green">
            {{ props.row.buyRate }}
        </q-td>
        <q-td key="spotRate" :props="props">
            {{ props.row.spotRate }}
        </q-td>
        <q-td key="sellRate" :props="props" class="text-red">
            {{ props.row.sellRate }}
        </q-td>
        <q-td key="symbol" :props="props">
            {{ props.row.symbol }}
        </q-td>
        <q-td key="status" :props="props">
            <q-chip
            :color="
              props.row.status == 'Active'
                ? 'green'
                : props.row.status == 'Inactive'
                ? 'red'
                : 'grey'
            "
            text-color="white"
            dense
            class="text-weight-bolder"
            square
            style="width: 70px"
            >{{ props.row.status }}
          </q-chip>
        </q-td>
        <q-td key="action" :props="props">
            <div class="q-gutter-sm">
              <q-btn dense color="blue" field="edit" icon="edit" @click="editItem(props.row)" />
            </div>
          </q-td> 
        </q-tr>
      </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.filter(col => col.name !== 'desc')" :key="col.name">
                <q-item-section>
                  <q-item-label>{{ col.label }}</q-item-label>
                </q-item-section>
                <q-item-section side>
                  <q-item-label v-if="col.name !== 'action'">{{ col.value }}</q-item-label>
                  <template v-else>
                    <q-btn dense color="blue" field="edit" icon="edit" @click="editItem(props.row)" ></q-btn>
                  </template>
                </q-item-section>
              </q-item>
            </q-list>
          </q-card>
        </div>
      </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>
    </q-table>
  </div>
</div>
              
            
!

CSS

              
                .q-chip__content {
  display: block;
  text-align: center;
}

<style lang="scss">
.my-btn .q-btn__content *{
  color: #000000;
}
</style>
              
            
!

JS

              
                new Vue({
  el: '#q-app',
  data() {
    return {
      model: null,
      options: [
        {
          label:1,
          value:1
        },
        {
          label:2,
          value:2
        }
      ],
      show_dialog: false,
      editedItem: {
        name: "",
        code: "",
        buyRate: "",
        spotRate: "",
        sellRate: "",
        symbol: "",
        status: ""
      },
      defaultItem: {
        name: "",
        code: "",
        buyRate: "",
        spotRate: "",
        sellRate: "",
        symbol: "",
        status: ""
      },
      filter: "",
      mode: "list",
      currencyColumns: [
        {
          name: "name",
          align: "left",
          label: "Name",
          field: "name",
          sortable: true
        },
        {
          name: "code",
          required: true,
          label: "Code",
          align: "left",
          field: "code",
          sortable: true
        },
        {
          name: "buyRate",
          align: "center",
          label: "Buy Rate",
          field: "buyRate",
          sortable: true
        },
        {
          name: "spotRate",
          align: "left",
          label: "Spot Rate",
          field: "spotRate",
          sortable: true
        },
        {
          name: "sellRate",
          align: "left",
          label: "Sell Rate",
          field: "sellRate",
          sortable: true
        },
        {
          name: "symbol",
          align: "left",
          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",
          sortable: true
        }
      ],
      currencyData: [
        {
          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"
        }
      ],
      pagination: {
        page: 1,
      },
      page: 1,
      totalRecord: 0,
      pageCount: 1,
    }
  },

 methods: {
    updateRow() {
      if (this.editedIndex > -1) {
        Object.assign(this.currencyData[this.editedIndex], this.editedItem);
      } else {
        this.currencyData.push(this.editedItem);
      }
      this.close()
        // Object.assign(this.currencyData[this.editedIndex], this.editedItem);
        // this.close()
    },
    editItem(item) {
      this.editedIndex = this.currencyData.indexOf(item);
      this.editedItem = Object.assign({}, item);
      this.show_dialog = true;
    },
    close () {
      this.show_dialog = false
      setTimeout(() => {
        this.editedItem = Object.assign({}, this.defaultItem)
        this.editedIndex = -1
      }, 300)
    }
  },
})
              
            
!
999px

Console