[[https://www.revelation.com/|Sign up on the Revelation Software website to have access to the most current content, and to be able to ask questions and get answers from the Revelation community]] ==== Optimal display of data in edit table when horizontal space is scarce (OpenInsight 32-bit Specific) ==== === At 28 JUL 2003 07:11:44AM Oystein Reigem wrote: === {{tag>"OpenInsight 32-bit Specific"}} I have an edit table where I display data from a set of table rows. The data is just for display, not editing. There are quite a few fields, i.e, a high number of edit table columns. There will be much variation as to which fields are filled in, and the values can vary much in length. If I use a predefined width for each column I will waste valuable horizontal space for some columns and have too little space for others. Having the user adjust the widths manually will waste valuable time for the user and is not a good solution. Therefore I would like to have some programming that adjusts the width of the columns automatically so that horizontal space is distributed among the columns in the best possible way. (In addition I'll use a tooltip or zoom feature that will allow each cell value to be shown in full.) I wonder if anybody out there has already had a look at this problem and has some code or ideas to share. If not I'll do my own work. What I need is some programming that adjusts the column widths when the edit table is filled in. One might also consider programming that kicks in later - when the user manually adjusts the width of a column, or adjusts the whole edit table (if it's set to Autosize width). Then the programming could try to readjust the (other) columns to maintain a good distribution of vertical space. But I think I'll be satisfied with something that does that initial adjustment. I have some ideas but don't want to spend time on elaborating unless somebody's interested. - Oystein - ---- === At 28 JUL 2003 12:23PM Matt Sorrell wrote: === Oy, I had a similar problem in a VB app that I wrote. I wanted the columns to be as big as they needed to be to display the current data, but not any larger. Eventually what I did was wrote a small "resize" routine. After the data table was filled, I called this routine. It then when through the table and determined what the maximum width was in each column. I then had to do some math to convert font sizes to twips. Once I had this number, I resized each column to the max width plus a small fudge factor for readability. If you would like, I can post or email you my resize routine code. Granted, it's in VB6, but the logic might be beneficial. msorrel@greyhound.com [url=http://www.greyhound.com]Greyhound Lines, Inc.[/url] ---- === At 28 JUL 2003 05:55PM Oystein Reigem wrote: === Matt, Thank you very much for your kind offer, but I already made a function that works fairly well. After I posted I tried to switch to a different task but I just couldn't put the issue down. My function is different from yours in that it tries to keep the total width of columns within the original total width - just redistribute the same horizontal space in a better way. I think that fits my situation better than a max width approach. Actually some of my values can be very wide, so I [i]must[/i] have some way of limiting the widths. I (my users) just have to live with not all the data showing. (They [i]can[/i] see the whole cell value in a tooltip window (balloon help) when they place the cursor above the cell.) My function [i]does[/i] consider the max widths. A high max width will contribute to the column width. But so will a high [i]average[/i] width. That will keep a column with e.g one very long value and many short ones from stealing too much space from a column with values of a more even length. With my function one can also specify minimum widths for each column. When space is rare a column is guaranteed to get its minimum width (unless all its values are so short that less space is needed). While writing this it occurs to me I need some form of maximum as well. I don't want extremely long values to grab too much space for their columns. Seems I'm not quite finished. :-) Also it occurs to me there's a flaw to my basic idea of letting the function do a "fair" distribution of scarce space. The result could be that all columns get a little bit less space than needed. In the extreme case all values would show truncated. Wouldn't it then be better to let some columns have more space, and some less? I think I will do some experiments on real data and see how it turns out, before I make things too complicated for myself. :-) - Oystein - ---- === At 29 JUL 2003 10:32AM Matt Sorrell wrote: === Oystein, I handled the minimum width issue a little differently than your approach. I just made sure that the column header text was the minimum width that I wanted, and I include the column headers in my calculation of max width. That way, even if a column has no table data, there is still the column header which will become the "max width." Glad you got an algorithm figured out, though. msorrel@greyhound.com [url=http://www.greyhound.com]Greyhound Lines, Inc.[/url] ---- === At 29 JUL 2003 05:00PM Oystein Reigem wrote: === Matt, [i]Glad you got an algorithm figured out, though.[/i] Huh? Not yet. I'm in the middle of a radical rethink. Typical me. :-) - Oystein - ---- === At 29 JUL 2003 07:20PM Don Miller - C3 Inc. wrote: === Oystein .. Radical .. [b]you[/b] .. say it isn't so. Don [[https://www.revelation.com/revweb/oecgi4p.php/O4W_HANDOFF?DESTN=O4W_RUN_FORM&INQID=NONWORKS_READ&SUMMARY=1&KEY=398AD73CD27A83CD85256D71003D7FE6|View this thread on the forum...]]