Efficiently Implementing Date Filtering in VueJS Tables

I have a query for all of you. I'm working with a table that contains student time information and dates for the quarter. I'm looking to implement a time picker so that instructors can filter and display data between specific dates.

Essentially, I want to utilize the Entry Time field to narrow down and present data from one date to another.

Check out my code snippet below:

<v-card>
        <v-card-title>
          Student Profile
          <v-spacer></v-spacer>              
        </v-card-title>
  <v-data-table :headers="headers2"
                :pagination.sync="pagination2"
                :items="profile"
                :search="search">
    <template slot="items" slot-scope="props">
      <td>{{ props.item.sid }}</td>
      <td class="text-xs-left">{{ props.item.firstName }}</td>
      <td class="text-xs-left">{{ props.item.lastName }}</td>
      <td class="text-xs-left">{{ props.item.course }}</td>
      <td class="text-xs-left">{{ props.item.entryTime }}</td>
      <td class="text-xs-left">{{ props.item.exitTime }}</td>
      <td class="text-xs-left">{{ props.item.duration }}</td>
    </template>
    <v-alert slot="no-results" :value="true" color="error" icon="warning">
      Your search for "{{ searchQuery }}" found no results.
    </v-alert>
  </v-data-table>
</v-card>

Approach

 methods: {
  editStudent(sid) {
    this.dialog = true;
    this.editedSid = sid;
    axios.get('/api/e', {
      params: {
        'sid': this.editedSid
      }
    }).then(response => {
      this.profile = response.data
    }).catch(e => {
      console.log(e)
    })
  }
}

Any recommendations or ideas?

Answer №1

To tackle this issue, you can create a "computed property" that will sift through the original data and utilize it instead.

Here's an example:

computed: {
 filteredItems(){

   return this.inventory.filter(item => {
      // Add your filter condition here
   });

 }
}

Afterward, make sure to use 'this.filteredItems' in place of 'this.inventory' when setting up the table.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

I often find myself yearning for the good old days of prototyping functions when initializing a new

I just created a module in nodejs called Test.js with the following code: function Test() { this.key = 'value'; } Test.prototype.foo = function () { return 'foo'; } module.exports = Test; Then, in B.js file: var Test = require(&a ...

Running and halting multiple intervals in Javascript - a guide

Imagine a scenario where I am setting up 3 intervals with times of 500ms, 1s, and 1.5s. When I click on the button for the 500ms interval, I want to stop the other two intervals and only run the 500ms one. The same goes for clicking on the 1s or 1.5s butto ...

Is it possible to generate a star rating system from an image using a decimal value?

Recently, I have been eager to convert a number into a star rating and stumbled upon this helpful post here: . The post perfectly explains what I am looking to achieve. Despite following the instructions provided, I am facing difficulties getting it to fun ...

Ways to confirm the presence of specific keys in a JSON:

After successfully converting an excel sheet's content into a JSON format, my next task is to perform some validation on it. The requirement is to ensure that the jsonData variable contains specific keys in a particular order: Breakfast, Lunch, Snack ...

Enhance user interface dynamically with additional components in ReactJS by rendering them onClick. Master the optimal

Just started using React and I'm really enjoying it. I have a scenario where the parent component renders both: A TagBuilderContainer (which contains initially 1 TagBuilderComponent) An "Add Tag" button with an onClick event (intended to add a new ...

Restrict magnification in THREE.js mousewheel interaction

Seeking advice on limiting zoom in and out of a model in three.js. I have explored trackball controls, but couldn't find a way to restrict zooming. I also experimented with orbit controls, but encountered issues when combined with trackball controls r ...

Tips for keeping the header section anchored to the top of the page

I am having trouble getting the menu bar and logo to stick at the top of my header section in the template. I have been trying different solutions, including using the sticky.js plugin for almost 4 days now but it's not working. I also have parallax e ...

Contrasting actions when submission occurs by pressing ENTER versus clicking the submit button

Incorporating an HTML form input element that utilizes a SearchBox from the Google Maps Places API for auto-completion is proving to be quite challenging. Within my JavaScript code, I have instantiated a SearchBox as shown below: var input = $('#spot ...

Implement a CSS rule when the menu is in an open state

Is there a way to modify the color of the hamburger icon when the menu is open? I'm unsure on how to approach this. My assumption is that I need to check if the 'active' class is present and then apply specific CSS code. You can view the s ...

Having trouble getting Bootstrap-select to function properly with dynamically populated options in Vuejs?

I encountered an issue while trying to implement bootstrap-select in my project. Initially, the pre-created select option functioned correctly. However, when the options of the select were dynamically generated, the plugin failed to work without any visibl ...

Using jQuery to insert a div class with PHP referenced

My variable stores a color name. Here is an example: <?php $myvar = blueColour; ?> I want to apply this value to the body of an html page using jQuery: <script type="text/javascript"> jQuery(body).addClass("<?php echo $myvar; ?>"); < ...

Is jQuery.each() failing to function properly in Firefox and Internet Explorer?

Having trouble with the $.each function behaving differently across browsers. I have lists with background images, and I want the parent div to fade in once these images finish loading. My code seems correct as there are no JavaScript errors in the conso ...

Tips for setting up OpenLayers demonstrations on a personal server?

Currently, I'm working with an older version of OpenLayers (4.6.2) and find the provided examples extremely helpful for testing and reference purposes. However, the official web page with updated examples only includes the latest version. I am wonder ...

Determine in uibmodal /route

Within my code, I have the following: var b = 1 var a = $uibModal.open({ ariaLabelledBy: 'modal-title', ariaDescribedBy: 'modal-body', templateUrl: 'enteModal.html', controller: 'enteCtrl', reso ...

Ways to designate a parent element in Vue Draggable when the element is lacking a child

I'm currently incorporating vue-draggable into my project from the following GitHub repository: https://github.com/SortableJS/Vue.Draggable Below is my ElementsList component: <div> <draggable v-model="newElement" :move ...

Socket.io filters incoming data for xss vulnerabilities

I am currently utilizing socket.io in expressjs 3 and I'm looking to sanitize incoming messages using express-validator. Here's the code snippet I have: var expressValidator = require('express-validator') , sanitize = require('exp ...

Transfer information(text) to the clipboard using Vue (Nuxt js)

When the vs-button is clicked, I want the value of single_download_link.pdfId to be copied to the clipboard. I attempted it like this, but it did not work. I do not want to use the v-clipboard node module. Can someone please assist me with this? Thank you. ...

Struggling to connect to an express route?

I'm currently working on a MERN project and I'm encountering a small issue. When trying to make a POST request to a specific route, Express throws a 404 error and tells me that it can't find the desired route. However, everything works perfe ...

Can anyone help me recreate the stacked bar chart seen in Apple Health's Cardio Fitness article using chart.js and Bootstrap tabs?

On Apple Health, there is a fascinating article titled "Learn About Cardio Fitness" (located in the Browse tab at the bottom > Activity, then scroll down). While reading the article, I came across a chart that caught my eye, and I am eager to replicate ...

Identifying flags that do not actually exist in flag-icon-css library

Please take a moment to review the code snippet provided. I have created a Datatable that contains countries along with their country codes. Within my code, I am generating HTML to display flag icons using the format flag-icon-COUNTRYCODE. However, some ...