evrencoskun / TableView

TableView is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells.
MIT License
3.15k stars 459 forks source link

Is it possible to merge cells? #96

Open SolidScorpion opened 6 years ago

SolidScorpion commented 6 years ago

Hello! First of all - love your library and this is a perfect fir for my current project. However I did not find a way to merge cells, so that one cell item's width would be 2x,3x etc. width of column width (column width should stay constant) There's a calendar design i'm working on implementing: https://i.imgur.com/muXs6X3.png So in order to show booking i decided to go with custom view, which will be placed inside every cell. And every cell will paint the booking depending on booking time and current cell's day (for instance if booking takes 3 days one cell paints start, second paints middle and last the ending) But this causes the dividers to be visible for every cell, so as a workaround i want to add cells that will be of width that represent the number of days they should occupy.

This is what i got as of now by using your library: https://imgur.com/Wvwk9oN As you could see, dividers obscure with view.

Is there also a way to customize dividers\divider colors for cells?

evrencoskun commented 6 years ago

Hi @SolidScorpion

Unfortunately, Merging Cells is not supported by TableView.

Is there also a way to customize dividers\divider colors for cells?

TableView has some functions to hide/Show seperators like;

You can also change the separator color using this attribute

<com.evrencoskun.tableview.TableView
    android:id="@+id/content_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"

    app:column_header_height="@dimen/column_header_height"
    app:row_header_width="@dimen/row_header_width"
    app:selected_color="@color/selected_background_color"
    app:shadow_color="@color/shadow_background_color"
    app:unselected_color="@color/unselected_background_color"
    app:separator_color="@color/seperator_color"
/>
SolidScorpion commented 6 years ago

Ok, thank you for your answer. Is it possible to set divider width?

evrencoskun commented 6 years ago

You can override the divider drawable creating a cell_line_divider.xml file on your project.

You can change whatever you want. However, I haven't tested the case. It may cause a problem when TableView calculates the right column width.

Martin-Hogge commented 6 years ago

Does merging capabilities is something planned on a future version? I need to get a table with headers like this:

-------------------------------------
|           My big header           |
-------------------------------------
| Small Header 1 | | Small Header 2 |
-------------------------------------
|     value 1    | |     value 2    | 
-------------------------------------

Where the the big header is taking the width of 2 cells.

Thanks.

evrencoskun commented 6 years ago

Hi @Martin-Hogge

Unfortunately, I do not have such a plan for a near future. :/

filipnbc commented 5 years ago

@SolidScorpion have you found a way to do it?

SolidScorpion commented 5 years ago

@SolidScorpion have you found a way to do it?

Sorry, but no. I'm no longer working on the project i needed it and we abandoned the idea of merging cells at that time

Mohamadkotb commented 3 years ago

@filipnbc Have you found a way to do it?

ankurt-optimus commented 3 years ago

i have done this in one of my projects i did using tableview, so what you do is make custom cells with top, button, left and right borders and then decide what are the cells you want to merge. After that since you always to full control over you cell design, when you're laying out you're cells, manage cells borders (hide or show borders) in such a way that cells appear to be merged together. Hope this helps.

On Sun, Feb 14, 2021 at 9:02 PM Mohamadkotb @.***> wrote:

@filipnbc https://github.com/filipnbc Have you found a way to do it?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/evrencoskun/TableView/issues/96#issuecomment-778793992, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABP3BLFHDLMVU26B4RK2VPTS67UJXANCNFSM4E55CXZQ .

filipnbc commented 3 years ago

I missed the question in Feb but yes, I was able to work around it.

  1. Extend AbstractTableAdapter
  2. inside onBindCellViewHolder calculate width
    int width = (int) DisplayUtils.convertDpToPixel(255 * span, inflater.getContext());

    where span is the number of columns.

Then set the layout width for the current cell/item either through data binding or through layout params.

You have to make sure though that the sum of all columns is the same, else you will end up with rows that move my themselves.