Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS [Solved] Dynamic width for various View

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #209880
    chandrabhan
    Participant

    Hi,
    I am struggling to get an idea to fix this problem.
    I have to display some data on screen. Now this data can be displayed in any form depending upon the settings in DB. Like Table or Grid.
    So if I have to show data in grid it should look like:

    Name :——————[COL1, ROW1] LastName:——————[COL2, ROW1]
    Address:————————————————-[COL1, ROW2]

    And for Table:
    Name | LastName | Address |

    Now the issue is I cannot save Width as ‘%’ or ‘pixels’ in DB as it would not make any sense, so I chose to set them as relative weight(like Name-Width:1,LastName-Width:2,Address-Width:4), For table it works fine as I convert them to ‘width%’ at time of render, but for grid it dose not make any sense.

    If there any other ideas to keep width in such a way that it can be controlled by DB for any or most of the possible layouts.

    Thanks in advance.

    #209882
    Paulie_D
    Member

    There’s a lot you could do if you can apply a class to a wrapper but without seeing what the output HTML is like.

    http://codepen.io/Paulie-D/pen/bVYyjv

    #209884
    chandrabhan
    Participant

    Thanks Paulie_D for the reply.

    The output HTML is very accurate as you displayed.
    The issue is I can save only a single value for name’s width in DB: either in pixels or in % or in relative weight.
    In the given example:

    .table .name {
    width: 25%;
    }

    .grid .name {
    width: 50%;
    }

    The value is different in both case(25 and 50 viz), I wanted to store in DB such info, that at time of table it converted in 25% and in gird it gets converted to 50%

    #209885
    Paulie_D
    Member

    The thing is that if you can add a class to the wrapper you don’t need store the value in the database at all….the CSS will deal with all of that.

    #209886
    chandrabhan
    Participant

    Dear Paulie_D

    The issues with this approach is that the number of field and its order is not fix, they can very. Also used wants to provide the width for each field from DB so that he can control the layout according to various media type(Web, PDF and excel.)
    So I need to put something for width in DB for these fields, and then transform the field as per various width(like in above example in case of table it should give 25% and in gird 50% )

    Or one option is that I can have two columns in DB(viz TableWidth and GridWidth) but it is not a very appreciated solution

    #209887
    Paulie_D
    Member

    Then I would suggest that this is not an easily solvable problem.

    Certainly not with CSS…javascript might be an option.

    There is no single property that will do this for you…providing two different layouts based on essentially the same CSS.

    #209888
    chandrabhan
    Participant

    Dear Paulie_D

    Thanks for the reply.
    For time being I will keep separate width per layout.

    It will do for now :-)

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘CSS’ is closed to new topics and replies.