Extjs custom grid row grouping - extjs

I met some problems with creating table using Extjs. My table has difficult structure
-------------------------------------------|
| | | 4 |
| | 2 ---------|
| | | 5 |
| 1 |---------------------------|
| | | 6 |
| | 3 ---------|
| | | 7 |
-------------------------------------------|
The data from the server are as following:
1 2 4
1 2 5
1 3 6
1 3 7
Every sequence is an array
I need them to be grouped as at the picture above.
Any ideas?

You can use PivotGrid. Example: http://dev.sencha.com/deploy/ext-3.4.0/examples/pivotgrid/simple.html
Unfortunately it is only available in Ext JS 3. It should be available in Ext JS 4.1 though.

It looks like you need to group on the first two columns but unfortunately Ext.data.Store only supports one level of grouping. You'll have to extend Store to support more and Ext.grid.feature.Grouping to take advantage of it.

Related

How to get max Version number from Version table in Database?

I am managing versions in my Application. I have made table name "Version". There are three separate column for "Major", "Minor" and "Bug". My version number are stored in table like this:
Id | Major | Minor | Bug | No
1 | 1 | 0 | 0 | 1.0.0
2 | 1 | 1 | 3 | 1.1.3
3 | 2 | 0 | 4 | 2.0.4
4 | 3 | 0 | 1 | 3.0.1
Here my max version should be 3.0.1 as it is highest in current scenario. I am unable to get this max record. My project is in .Net Core 3.0 and i am using entity framework core.
What i tried so far !
I was concatenating each version number like 1.0.0, 1.1.3 and so on, then i was getting list order by descending and was getting first or default. It was working good but for only single digits. When i try it on double digits it was not working.
var model =await DbSet.OrderByDescending(x => x.No).FirstOrDefaultAsync();
Can't you just order on multiple columns?
var model = await DbSet.OrderByDescending(x => x.Major).ThenByDescending(x => x.Minor).ThenByDescending(x => x.Bug).FirstOrDefaultAsync();

Implementing a Model in a Relational Database

I have a super-class/subclass hierarchical relationship as follows:
Super-class: IT Specialist
Sub-classes: Databases, Java, UNIX, PHP
Given that each instance of a super-class may not be a member of a subclass and a super-class instance may be a member of two or more sub-classes, how would I go about implementing this system?
I haven't been given any attributes to assign to the entities so I find this very vague and I'm at a loss where to start.
To get started, you would have one table that contains all of your super-classes (in your example case, there would only be IT Specialist, but it could also contain things like Networking Specialist, or Digital Specialist). I've included these to give a bit more flavour:
ID | Name |
-----------------------------
1 | IT Specialist |
2 | Networking Specialist |
3 | Digital Specialist |
You also would have another table that contains all of your sub-classes:
ID | Name |
--------------------
1 | Databases |
2 | Java |
3 | UNIX |
4 | PHP |
For example, let's say that a Networking Specialist needs to know about Databases, and a Digital Specialist needs to know about both Java and PHP. An IT Specialist would need to know all four fields listed above.
There are two possible ways to go about this. One such way would be to set 'flags' in the sub-class table:
ID | Name | Is_IT | Is_Networking | Is_Digital
----------------------------------------------------
1 | Databases | 1 | 1 | 0
2 | Java | 1 | 0 | 1
3 | UNIX | 1 | 0 | 0
4 | PHP | 1 | 0 | 1
Keep in mind, this is only using a small number of skills. If you started to have a lot of super-classes, the columns in the sub-class table could get out of hand pretty quickly.
Fortunately, you can also use something known as a bridging table (also known as an associative entity). Essentially, a bridging table allows you to have two foreign keys that are primary keys in another table, solving the problem of a many-to-many relationship.
You would set this up by having a new table that associates which sub-classes belong with which super-classes:
ID | Sub-class ID | Super-class ID |
-------------------------------------
1 | 1 | 1 |
2 | 1 | 2 |
3 | 2 | 1 |
4 | 2 | 3 |
5 | 3 | 1 |
6 | 4 | 1 |
7 | 4 | 3 |
Note that there are 'duplicates' in both the sub-class ID and super-class ID fields, yet no duplicates in the ID field. This is because the bridging table has unique IDs, which it uses to make independent associations. Sub-class 1 (Databases) needs to be associated to two different groups (IT Specialist and Networking Specialist). Thus, two different associations need to be formed.
Both approaches above give the same 'result'. The only real difference here is that a bridging table will give you more rows, while setting multiple flags will give you more columns. Obviously, the way in which you craft your query will be different as well.
Which of the two approaches you choose to go with really depends on how much data you're dealing with, and how much scope the database is going to have for expansion in the future :)
Hope this helps! :)

Spare parts Database (structure)

There is a database of spare parts for cars, and online search by the name of spare parts. The user can type in the search, for example "safety cushion" or "airbag" - and the search result should be the same.
Therefore, I need somehow to implement the aliases for names of spare parts, and the question is how to store them in the database? Until now I have only one option that comes in mind - to create an additional table
| id | name of part | alias_id |
-------------------------------------------------- ---------------
| 1 | airbag | 10 |
| 2 | safety cushion | 10 |
And add additional field "alias_id" to table containing all the spare parts, and search by this field...
Are there other better options?
If I have understood correctly, it's best to have 3 tables in a many to many situation (if multiple parts have multiple aliases:
Table - Parts
| id | name of part |
-----------------------
| 1 | airbag |
| 2 | safety cushion |
Table - Aliases
| id | name of alias |
-----------------------
| 10 | AliasName |
Table - PartToAliases
| id | PartId | AliasId |
-------------------------
| 1 | 1 | 10 |
| 2 | 2 | 10 |
Your solution looks fine for the exact problem you described.
BUT what if someone writes safetycushion? or safety cuschion? With these kinds of variations your alias lookup table will soon become huge and and manualy maintaining these will not be feasible.
At that point you'll need a completely different approach (think full text search engine).
So if you are still sure you only need a couple of aliases your approach seems to be fine.

Extjs how to represent matrix in extjs

Is there any Extjs component to represent an editable matrix.
Something along these lines:
+------------------------------------+
| name | bid1 | bid2 | bid3 |
+------------------------------------+
| supplier A | |
| supplier B | |
| supplier c | |
+------------------------------------+
Like an editable grid? Have you looked at all of the grid samples?
You are looking for a pivot table. Options:
https://market.sencha.com/extensions/mzpivotgrid
or for extjs 3.4† :
http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.grid.PivotGrid
† (you can use 3 and 4 at the same time with the compatibility layer) http://www.sencha.com/blog/ext-js-3-to-4-migration/
Refer here. You can edit any entry in grid using editable grid panel.

Can the ExtJS GridPanel support column groups?

I would like to have a gridpanel with columns that are broken into 2 sub-columns, kind of like this:
| Monday | Tuesday | Wednesday | Thursday |
| In | Out | In | Out | In | Out | In | Out |
| 9 | 4 | 10 | 5 | 8:30| 4 | 10 | 5 |
Is this possible with ExtJS?
Yes, this is definitively possible. However, you will not find this as out-of-the-box functionality. There is a user extension/plugin (2.0 here) that should do the trick for you. There is also an example in the ExtGWT samples demo that has similar functionality.
In Ext 4.1.3 You can see http://docs.sencha.com/ext-js/4-1/#!/example/grid/group-header-grid.html
It supports group headers.

Resources