Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8660945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:22:53+00:00 2026-06-12T16:22:53+00:00

I have created a table on front end with several columns. The table with

  • 0

I have created a table on front end with several columns. The table with data looks something like below:

    ID         Name          Date1           Date2         Code1    
   00001        abc         2012/1/1         2012/1/10       1
   00002        def         2012/1/12        2012/2/1        1
   00002        def         2012/1/12        2012/2/1        2
   00002        def         2012/1/12        2012/2/1        3
   00003        xyz         2012/2/12        2012/3/1        2
   00003        xyz         2012/2/12        2012/3/1        4

Now I want to present data in above table in grouped manner i.e. every unique Id has only 1 row and all the code columns merged and displayed as 1 row.

    ID         Name          Date1           Date2         Code1    
   00001        abc         2012/1/1         2012/1/10       1
                                                             1
   00002        def         2012/1/12        2012/2/1        2                              
                                                             3
   00003        xyz         2012/2/12        2012/3/1        2
                                                             4

Please ignore my formatting style. Is this possible to do it programmatic when I do not have information about the number of code values coming? Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:22:54+00:00Added an answer on June 12, 2026 at 4:22 pm

    This function will remove the contents of cells which duplicate the content of the cell above them. It won’t merge them (à la rowspan / colspan), but it will empty them.

    function emptyDittoCells(table) {
        if (!(table instanceof jQuery && table.is("table")))
            throw "bad parameter";
    
        table.find('tr').each(function(rowElement) {
            var row = $(rowElement);
            var previousRow = $(rowElement).prev('tr');
            if (!previousRow.length) return;
    
            row.each(function(cellElement, index) {
                var cell = $(cellElement);
                var previousCell = previousRow.children("td:nth-child(" + index + ")"); 
    
                while (previousCell.data('ditto')) {
                    previousCell = previousCell.data('ditto');
                }
    
                if (hasSameContents(cell, previousCell)) {
                    cell.empty()
                        .data('ditto', previousCell);
                }
            });
        });
    }
    
    function hasSameContents(a, b) {
        return (a.text() == b.text()); // naive but usable in the simple case
    }
    

    untested and a little DOM-intensive, but I think it’ll work. Besides possible syntax errors (missing close-parentheses), I’m mostly concerned about that td:nth-child() selector. That could be written more robustly as $(previousRow.children('td').get(index)).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Created a table like CREATE TABLE [dbo].[tab1]( [Id] [int] NOT NULL, [Name]
I have created table and inserted values as below. create table mytable (id INT,
I have created a table in Visual Studio. That table has two columns. First
I have created a table with the following columns: ObservationId, FirstCreatedDate, description, ... ...
I have created one table using the below command: create table Table1( Id int
I have a table called as Activity with columns like activity_id and activity_date .
In my fictional database, I have several columns of data. In designing a PHP
I have created the following drop down for my front-end webpage: <select> <option value=All>All</option>
I have created a table view with navigation controller. I want to link table
I have created a table layout in which my table row height is too

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.