<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ardian Ibrahimi on Medium]]></title>
        <description><![CDATA[Stories by Ardian Ibrahimi on Medium]]></description>
        <link>https://medium.com/@ardianxibrahimi?source=rss-bc1c27fa8807------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*syvZDCzCIlsP09OD</url>
            <title>Stories by Ardian Ibrahimi on Medium</title>
            <link>https://medium.com/@ardianxibrahimi?source=rss-bc1c27fa8807------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 17:41:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ardianxibrahimi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Fully dynamic data-table component for Vue.JS]]></title>
            <link>https://levelup.gitconnected.com/fully-dynamic-data-table-component-for-vue-js-c72cdb6cff92?source=rss-bc1c27fa8807------2</link>
            <guid isPermaLink="false">https://medium.com/p/c72cdb6cff92</guid>
            <category><![CDATA[table]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Ardian Ibrahimi]]></dc:creator>
            <pubDate>Mon, 04 May 2020 00:38:21 GMT</pubDate>
            <atom:updated>2020-05-06T02:33:59.869Z</atom:updated>
            <content:encoded><![CDATA[<h3>Intro</h3><p>The following article is meant for entry level front end developers who already have had an introduction to reactive/progressive javascript frameworks and SPA development. You will be able to see how a fully dynamic data table is created and alongside that process get acquainted with VueJS syntax, data flow, and components.</p><p>If you aren’t really familiar with the concept of SPA development, no worries! You can quickly catch up with the concepts by checking out the awesome Vue framework <a href="https://vuejs.org/v2/guide/">documentation</a>.</p><h3>Getting started</h3><p>The first thing we are going to need is to set up a VueJS project using Vue CLI. Throughout this project we are going to rely on NPM packages so make sure to have NodeJS setup globally in your machine. In order to create your app through the CLI, you first need to install it globally through your terminal:</p><pre><strong>npm install -g @vue/cli</strong></pre><p>Now that we have Vue CLI in our belt, you can go ahead and create the project in whatever directory we want using the following command:</p><pre><strong>vue create your-project-name</strong></pre><p>After you execute the above command, Vue CLI will offer you predefined config options for the project, go ahead and manually select them so you can see for yourself what it has to offer:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*JtdV92y1nJaAO5OXzvghVA.png" /><figcaption>Figure 1.1 — Vue CLI feature dependencies</figcaption></figure><p>There will also be follow up option configuration (i.e CSS processors like node-sass) and how those config files will be structured within the application, I’ve selected node-sass for CSS pre-processing, Jest for testing and package.json file as the main configuration file.</p><p>After the project has been created we simply move to the newly created folder, use <strong><em>npm run serve</em></strong><em> </em>and you’ll find your freshly baked Vue app being served @ <strong>localhost:8080</strong> .</p><h3><strong>Getting to know the Project files structure</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*140_TFm8hayH-AJEyNdyLg.png" /><figcaption>Fig 1.2 — Project structure</figcaption></figure><p>So your project structure should look something like this with bold emphasis on the <strong><em>src </em></strong>directory where our source code will be developed and maintained in the future. Node_modules holds the black box magic regarding our development and even production dependencies (third party libraries) or which will later be bundled into a big chunk of a javascript file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5ad392a81cfae070e51ee0e912183792/href">https://medium.com/media/5ad392a81cfae070e51ee0e912183792/href</a></iframe><p>As you can see in the left code snippet, you’ll find the predefined routes from Vue CLI project setup so basically you have a few options here, either create a new route with a distinct path and component or modify the first route’s component or keep working on the existing Home component. I’m going ahead and creating a new view (<strong>Main.vue</strong>) which will hold the main data table component and will replace the home path directing to my new view.</p><h3>Starting with the main components</h3><p>Next what we want to do is to keep a healthy and constructive pattern of component-based thinking. What we know so far is that we are going to build a dynamic table. Hence from the naming itself, we know that there must be a wrapping component i.e <strong><em>Table.vue</em></strong>. Integral parts of any table are its headers and rows so these parts/components shall be defined and implemented separately : <strong><em>TableRow.vue</em>, TableHeader.vue</strong>.</p><p>Even though this is not a big project, it is best practice to know where to put your integral parts of the application so components will go under the <em>src — components </em>directory and views will be part of its own folder.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2980f32607c97fe9ff4e1c0bd728e376/href">https://medium.com/media/2980f32607c97fe9ff4e1c0bd728e376/href</a></iframe><p>On the above snippet you will find the backbone of our component and what we are doing here, parent Table component and it’s respective Header and Row child components. As you can see from line 25 of the gist, I’ve created an array within the data property of our component and it’s obviously dummy data so we can go ahead with finally displaying a table in our <em>Main.vue</em> view.</p><blockquote>In easier terms you can consider <strong>data</strong> as a source of variables/objects/arrays that are part of the component and could be used throughout it.</blockquote><p>The integral part of this component of course will be some sort of data that you would <em>ideally </em>fetch from a backend service and later on retrieve from your very own app state powered by <a href="https://vuex.vuejs.org/">Vuex</a>… that’s why I’ve written down <em>tableHeaders()</em> and <em>tableRows()</em> as computed properties which will be directly derived from one state property from our centralised Vuex store. The values of these computed properties are passed in as <strong><em>props </em></strong>to the child table components and are expected and treated as such inside those very components as following :</p><pre>&lt;template&gt;<br> &lt;div&gt;<br>   {{propName}}<br> &lt;/div&gt;<br>&lt;/template&gt;</pre><pre>...<br>props[&#39;propName&#39;]<br>...</pre><p>The main idea behind all the dynamic part of this component was to come up with a way to get the right amount of keys and respective values per object and that’s why both operations in the above mentioned computed properties come in handy. Through its callback mechanism, <strong>map </strong>iterates each object and returns a new array depending on how we curate our own object according to our own needs. Here I heavily relied on getting the keys and their indexes and also getting values paired with their keys for each specific row.</p><h3>A glimpse into VueX — State operations</h3><p>In today&#39;s SPA’s you will rarely find one which does not communicate with a third-party service through HTTP but usually all of them have some sort of state management going on, and because of that whenever such applications are being developed it is best to separate communication and state changes activities/events. VueJS offers <em>actions</em> and <em>mutations</em> and on a high level concept you can consider them as both operations which are involved in state changes.</p><blockquote>As per it’s official documentation Vuex tells us that the only way to change our application state is to <strong>commit </strong>mutations towards specific parts of the state, and the thing that differs actions from mutations is that the former simply initiates/commits a mutation and doesn’t directly change the state, and due to their compatibility to offer asynchronous operations, it’s best practice that third-party API/backend service calls to be initiated by actions and whatever the result is to be reflected onto the application state through committed mutations.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b21775187952195a1f40a1359fb9f88/href">https://medium.com/media/8b21775187952195a1f40a1359fb9f88/href</a></iframe><p>In the above gist you will see that I’ve modified our created-by-vuecli store by adding mutations, actions and a new state property <em>tableData </em>which was, as you recall correctly our <em>data property </em>inside our Table component. You can ‘inline’ define your own actions and mutations inside the main <em>index.js </em>file, but generally that’s not preferred because as soon as the codebase expands and new features are coming up on the horizon, having separated actions, mutations and even common utility functions in their separate files will be a big advantage for further code maintainability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hpNBA8NR82Yhv2RR_tPrng.png" /><figcaption>Fig 1.3 Component — Store reflection</figcaption></figure><p>I’ve also added a known VueJS component lifecycle hook (among many), <em>beforeMount</em> which as the name implies, before the component is mounted for and rendered, it initiates an action which retrieves the required tableData for our table component and as you can see in the above picture (alongside with VueJS dev tools), the computed properties are populated through the main vuex binding which reflects the central state property <em>tableData</em>.</p><h3>Some final touches</h3><p>Before you continue, if you do not have a third party API or backend service from which you can retrieve data, you can go ahead and checkout <a href="https://github.com/marak/Faker.js/">FakerJS</a> and using its methods in your <em>action</em> on the Vuex Store you can generate as many objects as you want with any keys that you like. Following, you can check out the CSS properties and practices I’ve used to come up with the end result which you can check at Fig 1.4 in this article.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a2cb65e0812f890456795ed45a31587c/href">https://medium.com/media/a2cb65e0812f890456795ed45a31587c/href</a></iframe><h3>The beginning</h3><p>By the end of this article and if you’ve followed through with the gists, you should come up with a table looking as the one below. Obviously it’s a simple component and not rocket science, but it’s a fun task to go through. This article is the first part of this project, the next part will focus on deployment and making this table component reachable as an NPM package so that anyone can use it by just installing it as a dependency and integrate it in their application as a component. In the meantime, I intend on implementing all the features that a fully functional table has i.e filtering, sorting, modifying and much more so feel free to follow up with the Github repo @ <a href="https://github.com/ardianche/zippytable">ZippyTable</a> .</p><p>Thank you for your time invested into reading this article, looking forward to your feedback in the comments!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*odzEMZ0AEL-jx85mh3dXiQ.png" /><figcaption>Fig 1.4 — End product</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c72cdb6cff92" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/fully-dynamic-data-table-component-for-vue-js-c72cdb6cff92">Fully dynamic data-table component for Vue.JS</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>