We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Product/Category Mapping Table

Hi
I have a product table:
     Product Id, Product Description

A Category table:
    Category ID, Category Description

A product can belong to many categories and a category can contain many products.

So I also have a Category/Product table that lists all products and their categories
e.g.

data: 

      [
                {
                  "CategoryID": 1,
                  "CategoryName": "Milk, Cheese & Yogurt",
                  "Product": 5000,
                  "ProductDescription": "Semi Skimmed Milk 1ltr"
                },
                {
                  "CategoryID": 2,
                  "CategoryName": "Tea, Coffee & Soft Drinks",
                  "Product": 5000,
                  "ProductDescription": "Semi Skimmed Milk 1ltr"
                },
                {
                  "CategoryID": 2,
                  "CategoryName": "Tea, Coffee & Soft Drinks",
                  "Product": 6000,
                  "ProductDescription": "Innocent Smoothie Strawberries & Bananas 750ml"
                },
                etc


To manage this relationship I want to display the current list of products grouped by category.

I have a table set up displaying these items grouped by Category and all is fine, I now want to allow the user to add a new product to a category. The first question, is this an appropriate solution or is the hierarchical functionality or the parent/foreign key functionality more appropriate than grouping - the document is great, but I cannot work out which is the most appropriate way to display this related data?

I now have some queries when it comes to editing.

I want the user to be able to enter a new category based on a category in the Category table, not limited to a category currently in the category/product table. Likewise, the product should be selected from a product in the product table. Is there a way to use a dropdown list populated from a second data source (i.e. the category and product tables)?
Finally ( I know I am asking a lot of questions here!), is it possible to have a "add' button at the bottom of each category, so I already know where a new products should be added (I would include all categories from the category table with empty rows where no product is in that category). This is icing on the cake, but if it can be easily done, then I would be keen to include in the app.

I would appreciate any advice.

Thank you

Kevin




6 Replies

TS Thavasianand Sankaranarayanan Syncfusion Team December 31, 2019 04:38 PM UTC

Hi Kevin, 

Greetings from Syncfusion support. 

Query #1: is this an appropriate solution or is the hierarchical functionality or the parent/foreign key functionality more appropriate than grouping - the document is great, but I cannot work out which is the most appropriate way to display this related data? 
 
We need some more details to proceed further on your requirement. So, please provide the following details 
  1.  We have shared the screenshot and documentation of Hierarchical grid. for Hierarchical grid we must have one same field in both the parent grid and child grid.
  2. Are you want add data in both child grid and parent grid ?
  3. Are you want to show the grid like Hierarchical or not ? if no please share details about how to show your grid.



 


Query #2:  is it possible to have a "add' button at the bottom of each category 
 
Please share more details about this query. Share any screenshots or pictorial representation about your requirement of how to show the button. 

Regards, 
Thavasianand S. 



JJ Jayabharathi J Syncfusion Team January 2, 2020 11:14 AM UTC

Hi Thavasianand  

Thank you for your clarification questions.  

Having reviewed the hierarchical API, I do not think I need this.  
I have a table to manage products, a table to manage categories and the table I am interested in is the connecting table - Category/Product. This table does not update the category or product table. 

As you will see from the screenshot, the table has Category ID and description and Product ID (EAN) and description, along with an optional start and end date. Ideally, I would like to have an 'Add' button associated with each group, even if there is an empty group (i.e. a category with no products). When a user chooses Add, the form either displays the category ID and description as read-only fields and the user selects the product and dates OR the form only allows the user to select product details and dates and the category details are automatically populated on save. As with the original requirement  - the product Id is limited to a selection from the product table.  
 
Thank you 

Kevin 



KE kevindev January 6, 2020 04:30 PM UTC

Hi

Instead of having a custom add button on each row, I have used two dropdown widgets, one for the category and one for the product that achieves the same functionality.

Thank you

Kevin


PK Prasanna Kumar Viswanathan Syncfusion Team January 7, 2020 05:03 PM UTC

Hi Kevin, 
 
Before we provide solution we need some clarifications based on the query, 
 
1. In previous update you have mentioned that you would like to have a “Add” button associated with each group. But in last update you need to use the dropdown widgets instead of “Add” button in each row. So, do you need to render the dropdown controls (one for the category and one for the product) in each row? 
 
2. In previous update you also mentioned that when the user chooses “Add” button the form either displays the category ID and description as read-only fields. Here, when we click on “Add” button do you need to add new record (input form elements) as like below screenshot? 
 
 
 
3. If we replace dropdown widgets with a “Add” button, then how can we add new record in Grid? 
 
4. Please share the screenshot of your requirement. 
 
5. For the two dropdown widgets, do we need to add dataSource based on the “Product” and “Category”? 
 
Please share more information regarding the requirement, it will help us to provide solution ASAP. 
 
Regards, 
Prasanna Kumar N.S.V 



KE kevindev January 9, 2020 10:29 AM UTC

Hi Syncfusion

Apologies if my last response has caused confusion. I have identified an alternative solution that does not need the Add button at the group level, so please close this support ticket.


DR Dhivya Rajendran Syncfusion Team January 10, 2020 05:55 AM UTC

Hi Kevin, 

We have happy to hear that your problem has been resolved. Please get back to us if you need further assistance from us. 

Regards, 
R.Dhivya 


Loader.
Live Chat Icon For mobile
Up arrow icon