Solved

Updating Sort Order

Posted on 2007-11-19
3
233 Views
Last Modified: 2010-03-30
I have a User Interface where user can update the SortOrdr of any products or he can add a new product and can give a user defined sort order.Multiple products can be added and sortorder field is optional. I need to persist the sort order in the database after the user clicks save.So I have listed different scenarios on how sort oder should be updated.I need to write a stable sort or some logic to make sort order unique while persisting.Can you guys tell me where should I start?


Group Name      Product Name      Sort Order(Orginal)      Sort Order(new)    (updated) Sort
Group A            Product 1234                #1                                       #1                             #1
                          Product 1235               #2                                    #2                           #2
                          Product 1236               #3                                    #2                           #3
                          Product 1237               #4                                    #2                            #4


Group Name      Product Name      Sort Order(Orginal)      Sort Order(new)    (updated) Sort
Group A            Product 1234                #1                                       #1                             #1
                          Product 1235               #2                                    #2                           #2
                          Product 1236               #3                                    #2                           #3
                          Product 1237               #4                                    #3                            #4

Group Name      Product Name      Sort Order(Orginal)      Sort Order(new)    (updated) Sort
Group A            Product 1234                #1                                       #1                             #1
                          Product 1235               #2                                    #2                           #2
                          Product 1236               #3                                    #3                           #4
                          Product 1237               #4                                    #4                            #5
                          Product 1238                                                  #3                              #3

Group Name      Product Name      Sort Order(Orginal)      Sort Order(new)    (updated) Sort
Group A            Product 1234                #1                                       #1                             #1
                          Product 1235               #2                                                                    #4
                          Product 1236               #3                                    #2                           #2
                          Product 1237               #4                                                                         #5
                          Product 1238            #5                                   #3                             #3
0
Comment
Question by:Vasantreddy
3 Comments
 
LVL 5

Accepted Solution

by:
mfsamuel earned 500 total points
ID: 20321851
You will need to create a new table to store the user preferences.  It appears that you are planning on haveing each user/group combination have a unique sort order.

Without knowing specific database leve details, create a table with columns
preference_id (pk)
group_id
user_id
product_id
order

When you are generating the page to display the data you innner/left join against the preferences table and order by the the order column.

The mechanics of the sort can happen at the database layer, your application will just need to update the table to preserve the structure.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Weekend adv creator 3 54
java stored proc example 9 46
Html Table Looping (part 2) 5 28
convert Systemjs to Webpack 3 36
Iteration: Iteration is repetition of a process. A student who goes to school repeats the process of going to school everyday until graduation. We go to grocery store at least once or twice a month to buy products. We repeat this process every mont…
When there is a disconnect between the intentions of their creator and the recipient, when algorithms go awry, they can have disastrous consequences.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question