Vuejs table with dynamic columns connectted to flask API - rest

I am building a web application using Flask, SQLAlchemy and Vuejs. I have built an API to pass data from my database to be displayed in a table, built as a Vuejs component. I want my table component to be as generic as possible so I reuse it in different places.
For my first attempt, my API returns data as follows:
data = [
{
firstName: ‘Joe’,
lastName: ‘Bradley’,
email: ‘joe#company.com
},
{
firstName: ‘Mary’,
lastName: ‘Kelly’,
email: ‘mary#company.com
},
{etc....}
]
Right now my Vue table component has column headings hard coded in but, I want the table component to be able to dynamically change the number of columns based on what data it receives. I don’t want the headings to be hard coded. I might have a different table that displays 4 totally different columns of data. How should I set the column headings in the Vue component?
Some ideas I had:
Include a list of columns headings in the API response so that the
table know what headings to use?
Make a separate API end point that returns a mapping of column
headings to database field names.
Just hard code the headings into the Vue table and define a new table
component for each time I want to display a different data set.
Can anybody offer any best practise advice for a situation like this? I’m self taught and pretty new to this as you have probably gathered from the question. Thanks in advance!

Related

How to relate a column to the row rather than the other way in anylogic

I have created a database in anylogic. Previously, I have related the information in the row to the columnn, i.e. there is a component in the row, and its properties are in the columns, and have put this in a function. Now I want to make the component the column and the properties, but don't know how to make it all relate. Below is the code I've written for the former:
site = selectFrom(parameters) .where(parameters.box_number.eq(boxNumber)) .where(parameters.site.eq(site)) .firstResult(parameters.site);
So box_number is the component and site is one of the properties. With this method, site is a column, but I want it to be a row.
You should use the SELECT WHERE SQL syntax, see https://help.anylogic.com/index.jsp?topic=%2Fcom.anylogic.help%2Fhtml%2Fconnectivity%2Fquerying.html&resultof=%22%73%65%6c%65%63%74%22%20%22%77%68%65%72%65%22%20
You can filter and load data in any format. Also, best use the database query wizard to help:

Can I display custom tags of columns in a database diagram?

I am trying to use database diagrams in Sparx EA to collect and communicate information about how we are using tables.
I want to add information to columns and have this information show up in a diagram.
For example, the first thing I want to do is note which columns are required in a given application.
I have used the reverse-engineering to import all the many tables into my Sparx project.
It looks like I can extend column information with Tags at least.
But I can't find a way to show my custom tags in a diagram, such as a basic database diagram with tables.
Is there a way to visualize custom tag information for columns in a diagram?
What seems like the most direct example would be such as the following, where a custom "usage" Tag appears after the column name and data type ...
I welcome other options such as conditionally changing the color or font or something based on the Tag,
if adding the Tag name & value is not possible.

FileMaker - Getting Data From Another Table with Multiple Field Restrictions

I can't think of a better title, so feel free to make a suggestion once you understand the issue.
I was given a table to work with that I need to call from another table:
Name
Month
Type
Value
For each record in the main table I need to pull one "Value" that corresponds to it. What it is will be determined by all three of the other fields. So for example, if a record in the main table is:
Name:
Google
Date:
3\17\2016
Type:
M
Then I need to pull the value for the record in the other table where the Name is "Google", the month is "3", and the type is "M".
I was able to do this successfully (if slowly) using an ExecuteSQL command in a calculation field, with a ton of nested If statements for the names (I have yet to figure out how to input the record's data directly into the ExecuteSQL statement, it breaks when I try). I would prefer to just grab the data directly. I can't switch over to the other layout because I need to see all of the records at once. I can't do a simple relationship because there isn't a real relationship, it's like there are three foreign keys working in tandem and I only know how to use one to call the data.
Any idea on how to do this more simplistically?
Some ideas I've had but not sure if it will work:
Using a calculation field as a related field to dynamically point to the row by code (concatenate the three relevant fields into a type of code). Not sure if you can connect two tables by a calculation field.
Doing that same thing when calling the data into the table in the first place, adding a code to create a single primary key.
Here are my relationships:
I can't do a simple relationship because there isn't a real
relationship, it's like there are three foreign keys working in tandem
and I only know how to use one to call the data.
Simply define a relationship with three predicates - i.e. three pairs of match fields.

Automating a data feed into a PostgreSQL table when the number of columns could change and there are duplicate names

My company uses a third-party vendor to get all of our NPS information. I'm trying to set up a data feed from this vendor into our data warehouse, which runs PostgreSQL.
The feed is in the form of 2 tab-separated text files: "question mapping" and the responses. The question map is one row per question, with columns for question id, question text, question label question type, etc - straightforward. The responses are one row per survey response, with a column for each question and stuff like user id, etc. Here are the 2 biggest problems:
The survey questions sometimes use the same question ID for different questions, resulting in multiple columns in the response data having the same name but not being the same question.
The number of questions could change, resulting in a different number of columns in the data.
Both of these things make it a real headache to automate a data feed into a single table.
I'm afraid I don't quite know how to phrase my real question other than, "Does anyone have any ideas how I can accomplish this?" If I think of something better than that, I'll come and update this, so for now:
Does anyone have any ideas at all about how I can efficiently set up my automated data feed without having to always drop and recreate everything?
If your data is a mess and doesn't really have well defined columns you can use the entity attribute value pattern, where you turn each fact into a set of rows with 4 columns - a unique row id, the same entity id for each row extracted from the map, an attribute column (where you put what would be the name of the column) you get from the key of the map, and a value column where you put the value from the map. It's not that neat but you can still query it and you won't have to drop it when you receive a map with a new column.

Telerik MVC: Generic Grid

I am wondering if I could design a generic way to design a Telerik MVC Grid.
Example:
Model is a List of FieldDescriptor. A FieldDescriptor has a name, a value and a type.
Thus I want to show the colums of the Grid according to the data in the model - depending on which fields come and what their type is.
But the Telerik MVC Grid only knows how to make a column, if you explicitly refer a model property.
I found a blog that explained what I think you are asking. How to display a dynamic datatable when you don't know what the columns are until run time.
You can loop through the columns in model to build the grid, then use ajax to go get the data.
Here the link www.alexrogan.com
Here is how you can loop through the column values of a datatable to create the grid columns.
.Columns(columns =>
{
foreach (System.Data.DataColumn column in Model.Columns)
{
columns.Bound(column.DataType, column.ColumnName);
}
})