How to make Grouping Entities Table widget in Thingsboard? - widget

I created a widget with Entities Table widget where data is presented in table like this :
I want to ask how to make grouping entity table widget or is it possible to create Entities Table widget similar like Hierarchy Widget in Widget Table Widget or As shown below :
Can the Entities Table widget display the data by grouping?

This is not possible with default Entities Table Widget, but you could develop your own custom widget for this purpose.
There are a lot of libraries available like e.g. DataTables:
https://datatables.net/
https://datatables.net/extensions/rowgroup/
https://datatables.net/examples/advanced_init/row_grouping.html

Related

How to create dynamic models with attributes on form submit

I have some tables which are nothing but my company services(WAPT, MAPT, NAPT etc). these services are predefined but now team want to add new services with different attributes. They can able to add multiple service table with different columns. Is this possible.
I tried active_dynamic but it's about adding attributes to existing table but i need multiple tables here with dynamic attributes.

How to implement multiple JSON schemas per JSON data column in MySQL

I'm using javascript-based CAD configurators to load products (i.e. materials) to be configured into new products (separate table - i.e. widgets). My JSON data columns need to adapt and be valid for materials to be used in client-side configurators for the creation of different kinds of new widgets.
My thought is to add a "data_type" column where each "data_type" is associated with a JSON Schema schematic. This column could be a foreign key or a string as JSON Schemas could be stored in a table (a json "schema" column in a data_types table) or directory (tablename-datatype.schema.json).
At this stage, I'm thinking a data_types table would be more flexible and easier to maintain and serve schemas from. Additionally, this would enable schemas to be shared between tables and I could implement a versioning system to facilitate configurator evolution.
What are the options to implement multiple JSON schemas per column in MySQL? Are there better ways of accomplishing what I'm intending to?
In this use case:
I'm using javascript-based CAD configurators to load products (i.e. materials) to be configured into new products (separate table - i.e. widgets). My JSON data columns need to adapt and be valid for materials to be used in client-side configurators for the creation of different kinds of new widgets.
To facilitate flexible JSON schemas that can be validated and used with relation to individual JSON data columns in multiple tables, the structure I'll implement is:
JSON data is only for client-side processes. This data is related to MySQL entries that have columns and relations that are queried at a higher level. The JSON data requires a flexible architecture for client-side functionality.
Create a datum_schema table. Columns might include key (id), string (name), integer (version), and json (schema) columns. Schemas can be shared, ensure backwards compatibility, and served to multiple client-side technologies.
Tables where entries require a single JSON data record. Create a json column and a reference to a datum_schema record. In the use case, this would be configurators and widgets:
Creating configurators: you create a configurator and datum_schemas records. In the use case, I'll create two schemas: one for settings and one for inputs. Specific settings for loading a configurator instance are stored in a json column within the configurators table.
Configurator table entries store references to their setting and input schemas. User rights will enable some users to create only configurator entries and others to create entries and define schemas.
Creating widgets: as you're using a configurator to create a widget, widget json data will be the input values needed to recreate itself and a reference to its configurator record.
Tables where a single entry may need multiple JSON data records.
Create a separate table to store json data with references to the first table. In the use case, this would be materials.
Creating materials: in the materials table, an entry is made to store any higher level of queryable information (i.e category). In a separate material_data table, entries include a reference to the material, json data, and a reference to the datum_schema. If the material is used in a configurator, the json data will have been structured according to a datum_schema record created by the configurator.
Want to create new kinds of widgets? Define a configurator, the necessary schemas, and relevant material categories.
I believe this to be a reasonable solution but, as I'm new to MySQL and database design in general, I'd appreciate feedback.

Many-to-many and hierarchical database design

i'm designing a database and run into some problems:
I have a Document entity consisting of many fields. Mostly i want to use the same version of that document but sometimes users should be able to customize some of the fields for a specific usage of the document. Not customized fields should use the value of the parent document as a default. Changes to the parent document should get propagated to any not customized field of a specific usage.
I have a table Document:
Document:
id | field1| field2 | field3| parentDocumentId
For parent documents is parentDocumentId = Null. Customized usages of a document have the new value for the customized fields saved and for not customized fields simply null.
Is this a good design?
Furthermore the Document entity has a many-To-many relationship with another entity Course. My problem now is when i look at a row of Document with parentDocumentId != null and courses = null i can't determine if the relationship is either not customized by the user yet and i should use the value of the parent document or the field is customized by the user and simply has no courses. How can i solve that?
Thanks

Symfony 4 - How to dynamically add field in an entity?

I want to have a form where I can add new fields (columns) in an specific entity. Is there a function for this?
Kind regards
Adding a whole column to the table through an HTML form is a weird use case.
If you want to stick to the ORM way of managing the persisted data, you'll have to dynamically add properties to existing entities, which might be a sign of bad schema design.
What I would guess you probably need is an automated way to add this column to your Entity. In such a case I would use the maker bundle.
Supposing that your Entity is called Employee, all you have to do is to type in the following command:
bin/console make:entity
When you'll be asked for the Entity name, enter Employee. The interpreter will tell you that this entity exists and if you want to extend it with news fields, and there you go.

EF 4.2 Code First -- Image, Location, Product Entities Can't use list

I have product and location entities that may/may not have a collection of images.
I know I cannot create a list in the respective entities, but nor do I want to make an association in the Image entity for the other two.
I just want the Image Entity to have Id and file path.
Is there a way I can do this?
If the answer is I MUST create an association in the Image Entity for the other two, then that means whenever in the future I create a new entity that may/may not have photos, I have to modify the Image entity for the association and I do not like that idea.
Thanks in advance.
It sounds like you want a uni-directional relationship. Is this correct? So you want to access Collection<Image> from Product and Location, but not be able to access Product or Location from Image?
You can do this. In EF, the Image class will not have a navigational property to Product or Location -- it will just have Id and FilePath.
However in the database, the Image table will have columns for ProductId and LocationId. This is so that EF can manage the foreign key relationship and populate the collection propertes on Product and Location.
code:
modelBuilder.Entity<Product>.HasMany(p => p.Images).WithOptional()
.Map(d => d.MapKey("ProductId"));
modelBuilder.Entity<Location>.HasMany(p => p.Images).WithOptional()
.Map(d => d.MapKey("LocationId"));
When managing these in your application, you can just add images to the Images collection property on your principal entities (Product and Location) without having to set a navigation property from the dependent Image back to the principal (you can't since the foreign key properties are not present).
You could create two new tables, ProductImages and LocationImages, link to the collection from your Product and Locations, when you insert an item for either, insert a record that joins the image and the product.
That way, when you load your product or your location, you can check if there are any association images by checking the collection.