npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vuetifygentable

v2.6.5

Published

This is a generic table that can fetch data from api using VuetifyTableApi nuget package.

Downloads

9

Readme

vuetifygentable

Install through npm

npm install vuetifygentable

Import into your vue project

import gentable from 'vuetifygentable';
export default {
  components:{
    gentable
  }
}

Example, on the vue markup side.

<template>
  <v-row justify="center" align="center">
    <v-col cols="12" sm="8" md="6"> </v-col>
    <gentable
      :url="endPointUrl"
      title="Addresses List"
      :showContextMenu="true"
      ref="table"
      :serverSideMode="true"
      :makeUrlQuery="makeUrlQuery"
    >
      <v-btn color="blue" dark class="mr-4" slot="button" @click="reload">
        Refresh
      </v-btn>
      

      <template slot="contextMenuItems" slot-scope="rowItem">
        <li>
          <a @click.prevent="editRecord(rowItem)">View</a>
        </li>
      </template>
    </gentable>
  </v-row>
</template>
<script>
import gentable from "vuetifygentable";
export default {
  components: {
    gentable,
  },
  data() {
    return {
      row: {},
      selected: null,
      endPointUrl: "/addresses",
    };
  },
  methods: {
    reload() {
      //refresh
      this.$refs.table.refresh();
    },
    makeUrlQuery(searchTerm) {
      //formulate and advanced query
      return `/?search=${searchTerm}`;
    },
    editRecord(row) {
      //access the row item
      let item = row.rowItem.data;
      this.$axios
        .get("/addresses/" + item.id)
        .then((r) => {
          console.log(r.data);
        })
        .catch((e) => {
          console.log(e);
        });
    },
  },
};
</script>

This is compatible with VuetifyTableApi nuget package that was made for this purpose. In a .net core 5 application, you can use it like this through the nuget package console or through nuget package manager gui.

PM> Install-Package VuetifyTableApi 

Assuming using .net core, on the controller side, you can use the VuetifyTableApi like so. This part you can customize as you wish. More documentation it's on it's way for VuetifyTableApi.

[HttpGet]
public async Task<ActionResult<Table>> GetAddresses([FromQuery] DataRequest dataRequest)
{
    var tb = new Table();
    tb.skipHeaderVirtualProps = true;
    int maxRecords = dataRequest.maxRecords;
    string search = dataRequest.search;
    var query = _context.Addresses.AsNoTracking();
    if (!string.IsNullOrWhiteSpace(search))
    {
        query = query.Where(t =>
            t.StreetAddress.Contains(search)
            || t.City.Contains(search)
            || t.State.Contains(search)

            );
    }
    query = maxRecords == 0 ? query : query.Take(maxRecords);

        var result = await query.Select(
                    t => new
                    {
                        id = t.Id,
                        t.StreetAddress,
                        t.City,
                        t.State,
                        t.ZipCode,
                        t.CreatedAt,
                        t.UpdatedAt,
                        t.DeletedAt,
                    }
                   ).ToListAsync<object>();

        tb.rows = result;
        tb.SetHeaders<Address>();
    return tb;
}

You can use post method (:method="post") to pass in terms as objects for search so server side can handle the search. v-model="searchTerms" can be used to two way bind your search terms outside of gentable.

<template>
 <gentable
      :url="/addresses"
      title="Addresses List"
      :showContextMenu="true"
      ref="table"
      :serverSideMode="true"
      :method="post"
      v-model="searchTerms"
    >
     <v-btn color="blue" dark class="mr-4" 
        slot="button" 
        @click="advancedSearch"
        v-model="searchTerms"
        >
        Refresh
      </v-btn>
    
    </gentable>
</template>
<script>
import gentable from "vuetifygentable";
export default {
  components: {
    gentable,
  },
  data() {
    return {
      row: {},
      selected: null,
      searchTerms:[ //search terms can be two way binded as to compose complex searches terms
        {FieldName:"*",ValueOperator: "contains", SearchValue:this.search,ExpressionOperator:"and",},
      ]
    };
  },
  methods: {
    //we can trigger the search. The function will take terms in the v-model and send them via api.
    advancedSearch(){
      this.$refs.table.fetchItemsByTerm();
    },
    editRecord(row) {
      //access the row item
      let item = row.rowItem.data;
      this.$axios
        .get("/addresses/" + item.id)
        .then((r) => {
          console.log(r.data);
        })
        .catch((e) => {
          console.log(e);
        });
    },
  },
}
</script>