Duplicate value suppression

Duplicate value suppression

zkarjzkarj Posts: 4Questions: 0Answers: 0
edited January 2011 in General
Hi. Amazing job you've done with this. I'm using it as part of the WP-Table reloaded plugin for WordPress.

What I'd like to be able to do - which I don't think is currently supported - is to suppress cells where the cell above has the same value.

I think it should be a column property. By example, the following table...

A 1 2
B 1 7
B 2 5
C 4 9

...with such a property set on the first column would become...

A 1 2
B 1 7
. 2 5
C 4 9

This would logically have to be applied according to the current sort, filter and viewport on the table.

Possible?

Replies

  • zkarjzkarj Posts: 4Questions: 0Answers: 0
    edited January 2011
    Oops. Edited to try and make blank space where the second "B" was (i.e. ignore the dot). I hope you get my drift.
  • allanallan Posts: 63,113Questions: 1Answers: 10,395 Site admin
    You could do this by making us of fnDrawCallback to delete cell information that isn't needed on a post draw. One thing that would make it difficult in DataTables itself is paging - for example the duplicates might span multiple pages, but you would want the top row in the page to display the value - even if logically it's the sixth (or whatever) repeating time for that value. fnDrawCallback would make this much easier.

    I've done something similar - although not identical for this example: http://datatables.net/examples/advanced_init/row_grouping.html - it is checking duplicates and then inserting a new row to group things together. It might provide a useful starting point.

    Allan
  • zkarjzkarj Posts: 4Questions: 0Answers: 0
    I would imagine that the process would be to store the cell value for each column in a 'previous row' array and then make a comparison to this before filling out a cell in the current row.

    I have an 818 row table with 431 unique values in the first column, the rest being blank indicating repetition. I used to split the whole thing up manually (alphabetic ranges on that first column) but thought I could save myself a lot of hassle by using the pagination provided (to WP-Table reloaded) by DataTables. The trouble, of course, comes when the first row of a page is blank in that first column.

    For now I shall just populate the blank cells with duplicate info. Not ideal but correct. I'm setting up a completely new version of my site and trying to avoid any customisation at a code level where possible.

    It would be useful if this could be built in to DataTables. To my mind, this is a fairly common practice in print.
  • zkarjzkarj Posts: 4Questions: 0Answers: 0
    Aha! I solved the problem, though not with DataTables.

    The raw data is in a Google Spreadsheet. I just created a new sheet which automatically copies the names down into the blank cells. Then I created another one that grabs from the 'has-blanks' sheet except on every 50th row, when it grabs from the 'no-blanks' sheet. I've then set paging to 50 and not user changeable. Bingo!
This discussion has been closed.