Dynamic row heights for NSTableView

Hi everyone,
I just began writing OSX apps not too long ago. I'm having trouble with dynamically setting my row heights for an NSTableView. I've seen a really old solution where the subclass the view but I also found a solution posted by Corbin on Stack Overflow. However, I don't quite understand and am hoping someone has sample code?
For my usecase, I have a list of text of varying lengths and are displayed in a multi-line text field. The rows for the table cut off the text and so I'm trying to resize them to fit the text. When I check on the setRowSizeStyle to custom - it defaults to 71 and is fixed at 71. I hope someone can help me out. I think the solution posted by Corbin should solve my problem but I have no idea how to implement it.
Thanks

Etresoft, the function that you gave me for some reason constantly calculates the height as 39. Minus the fudge factor of 25 means I'm constantly getting 14 for my height for all rows and some of the text is cut off. I think it might be because I'm passing in the wrong size into my NSTextContainer.
Here's my code right now:
- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row
    Message *message = [thread objectAtIndex:row];
    NSTableColumn *tableColoumn = [conversationView
                                   tableColumnWithIdentifier:@"tableColumn"];
    if (tableColoumn)
        NSCell *dataCell = [tableColoumn dataCell];
        [dataCell setWraps:YES];
        [dataCell setStringValue:message.message];
        CGFloat height = [self calculateIdealHeightForSize:[dataCell cellSize] content:message.message];
        NSLog(@"Message: %@ Height: %f", message.message, height);
        return height;
    NSLog(@"No size found. Returning default size for 100.");
    return 100;
- (CGFloat) calculateIdealHeightForSize: (NSSize) size content: (NSString *) content
    NSTextStorage * storage =
    [[NSTextStorage alloc] initWithAttributedString:[[NSAttributedString alloc] initWithString: content ]];
    NSTextContainer * container =
    [[NSTextContainer alloc] initWithContainerSize: size];
    NSLayoutManager * manager = [[NSLayoutManager alloc] init];
    [manager addTextContainer: container];
    [storage addLayoutManager: manager];
    [manager glyphRangeForTextContainer: container];
    NSRect idealRect = [manager usedRectForTextContainer: container];
    // Include a fudge factor.
    return idealRect.size.height + 25;

Similar Messages

  • How to set the row height for a list control in flex 4.5 for mobile?

    Hi,
      I have a List in my Adobe Flash Builder 4.5 and flex 4.5 mobile application. I show the image and the label in my list. The list item height gets adjusted based on the image height. I don't want this auto row adjustment. Instead I would like to set the row height manually.
    Is there any property to set the item height in a list?

    setting rowHeight in the List layout works for me.
    <s:List>
    <s:layout>
    <s:VerticalLayout rowHeight="48"/>
    </s:layout>
    </s:List>

  • Dynamically stretch height for panelTabbed

    Hello,
    I have dynamical content (height of it can be changed by buttons) in one tab in panelTabbed.
    So I've tried to set the style for panelTabbed: inlineStyle="min-height:620px;" and I've expected that panelTabbed will be stretching in height. But it didn't.
    Is there any solutions for this problem? In documentation i've found that for stretching content <af:panelStretchLayout> should be used, but I failed to do this.
    Thank you.

    Try to use panelStretchLayout & its height/width can be stretched using topHeight/bottomHeight/startWidth/endWidth attributes.

  • How to set  row height  for  each row

    Hi
    i am trying to set rowheight of row in a JTable using setRowHeight(row,rowheight)
    it is not affecting on Table.but if i use setRowheight(rowheight) it applying
    entire table ,please help me to solve this problem
    after setRowHeight(row,rowheight), i am calling firechanged() method also ,i t will not affecting please hemp me
    how to set row height at runtime in a JTable

    Ok fine... do one thing... post ur code here let me check and tell u....
    Ciya.....

  • Dynamic table height for Printed PO Report

    I have created a RTF template for Printed Purchase Order report using Microsoft Word. The template has Header and Line information. I have two questions.
    1) Lines are printed in Table format. I also print header level notes in Line Section.
    If the header notes are blank, I want the line information (line #, Item Number, Description, quantity etc) to be moved to line1. How do I acheive this?
    I want to dynamically adjust the Table height based on the information printing in the line section. The table has two rows. One for Header notes and one for Line information.
    2) Header notes field is placed in Description column of Line Table (MS word). Currently Header notes are printing within the Description column as wrapped text. I want to print Header notes in one line. How do I expand this field to print in one line?
    Thanks,

    Hi,
    Even I faced the same problem, however I have found a workaround to come out of this problem.
    My PO design template has 16 lines, I am counting the number of lines with data and subtracting the same from 16 and inserting that many empty rows to increase the table height.
    I am pasting the code so that it will be useful for others.
    Paste this code before LINES_ROW for-each loop. This will give the number of lines present.
    <xsl:variable name="_XDOFOTOTAL" select="count(.//LINES_ROW)"/>
    Paste this code at the end of the for-each loop.
    <!-- 16 is the maximum number of rows which fits in my page.-->
    <xsl:variable name="_cnt" select="16-$_XDOFOTOTAL"/>
    <xsl:call-template name="countdown">
    <xsl:with-param name="countdown" select="16-$_XDOFOTOTAL"/>
    </xsl:call-template>
    This function you can put it at the end.
    <xsl:template name="countdown">
    <!-- Instead of for loop. -->
    <xsl:param name="countdown"/>
         <xsl:if test="$countdown">
              <fo:table-row keep-together="always">
              <fo:table-cell/>
              <fo:table-cell>
              <fo:block height="13.2pt"/>
              </fo:table-cell>
              <fo:table-cell>
              <fo:block height="13.2pt"/>
              </fo:table-cell>
              <fo:table-cell xdofo:use-attribute-sets="c_33 c_35">
              <fo:block height="13.2pt"/>
              </fo:table-cell>
              <fo:table-cell xdofo:use-attribute-sets="c_33 c_35">
              <fo:block height="13.2pt"/>
              </fo:table-cell>
              <fo:table-cell>
              <fo:block height="13.2pt"/>
              </fo:table-cell>
              <fo:table-cell>
              <fo:block height="13.2pt"/>
              </fo:table-cell>
              <fo:table-cell>
              <fo:block height="13.2pt"/>
              </fo:table-cell>
              <fo:table-cell/>
              </fo:table-row>
              <!-- Call the template again -->
              <!-- The below code is like x=x-1 -->
              <xsl:call-template name="countdown">
                   <xsl:with-param name="countdown" select="$countdown - 1"/>
              </xsl:call-template>
         </xsl:if>
    </xsl:template>
    If some one is having a better solution, please share.
    Regards,
    SURESH KUMAR M R

  • JTable and adjusting Row height

    Hi,
    How to make a row height adjustable, like user can click on the row and drap to increase the height of the row,
    Also if i have JTextArea as cell rendere how do i dynamically adjust the row height to display all the text
    Ashish

    That's a lot of questions..... but here are your answers:
    1. Can we adjust variable row height for each row,Yes, use JTable's setRowHeight method to set the height of each row.
    2. Also as we adjust the column widht, can we adjust the row height by dragging,You should be able to adjust the column width by clicking the mouse on the edge of the column header and drag. There is no automatic provision for changing the row height that way -- you'll have to add a mouse listener to the rowheader and write your own code to perform the resizing.
    3.Suppose i have JTextArea as a cell renderer , how can i display all the text in a row with out having to use a scroll bar, You'll have to figure out how many rows (based on the sum of the individual row's height) the textarea occupies (taking into consideration the font that you used to render the textarea). I have my own way of doing things but if you search this forum, you'll find a lot of discussion on how to do it.
    ;o)
    V.V.

  • Numeric Row Height Value Fixed but Different

    Hi Everyone,
    On my front panel, I have a 1D array (column) of Numerics next to a 1D array (column) of strings. I need them to line up. I believe that the row height for numerics is not changeable, but for strings you can change it.
    Here is my problem, on different PCs I have found that the numeric row heights have different fixed values. On my development PC (LabVIEW 2011, 32 bit), the row height is 22 pixels. On all other test PCs (also LabVIEW 2011, 32 bit) the row height is 20 pixels. I need the arrays to line up on all PCs, but it looks different.
    Does anyone have any suggestions on how I can fix this issue?
    Solved!
    Go to Solution.

    "Get Text rect.vi"will tell you how big the bounding rectangle is for text rendered using the font you choose while also concidering "Bold" etc.
    Using that function should give you a way of dtermining how large the text ends-up being and then you JUST* have to sett all of the proeprties to match.
    Ben
    * yes, the word "JUST" is a four letter word in my book as well.
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Row height in excel

    Can I create a macro to automaticaly double the row height for parents?Thanks Joe

    Hi Joe,Here is a simple macro to take the selection and set the row height:Option Explicit''' takes a selected range and''' doubles the size of the row''' if the row contains a parent''' (signified by an indent on''' the member name/indent totals''' option in Essbase)Sub MakeParentRowsBig() Dim oCell As Range Dim dStdHeight As Double ''' get the standard height dStdHeight = _ ActiveSheet.StandardHeight ''' loop the cells in the selection For Each oCell In Selection ''' if spaces on the front If Len(oCell.Value) <> _ Len(LTrim(oCell.Value)) Then oCell.EntireRow.RowHeight = _ dStdHeight * 2 Else oCell.EntireRow.RowHeight = _ dStdHeight End If Next oCellEnd Sub

  • JTable and Adjusrt Row Height

    Hi,
    1. Can we adjust variable row height for each row,
    2. Also as we adjust the column widht, can we adjust the row height by dragging,
    3.Suppose i have JTextArea as a cell renderer , how can i display all the text in a row with out having to use a scroll bar,
    Ashish

    That's a lot of questions..... but here are your answers:
    1. Can we adjust variable row height for each row,Yes, use JTable's setRowHeight method to set the height of each row.
    2. Also as we adjust the column widht, can we adjust the row height by dragging,You should be able to adjust the column width by clicking the mouse on the edge of the column header and drag. There is no automatic provision for changing the row height that way -- you'll have to add a mouse listener to the rowheader and write your own code to perform the resizing.
    3.Suppose i have JTextArea as a cell renderer , how can i display all the text in a row with out having to use a scroll bar, You'll have to figure out how many rows (based on the sum of the individual row's height) the textarea occupies (taking into consideration the font that you used to render the textarea). I have my own way of doing things but if you search this forum, you'll find a lot of discussion on how to do it.
    ;o)
    V.V.

  • One row height

    Hi all. I have a table with a specific width and height. I need rows to be shown in one line (one row height). In my case, if the cell content is too large (it has a lot of data), the row height grows in two or more rows, because it shows the whole data. I'm not interesting in showing the whole data, but I'm interesting in keeping the row height for all the rows in the table (one row height).

    Hopefully, I am understanding what you want. I have 2 suggestions.
    1. Modify your sql statement to return a substring. For example, if your table column is about 20 chars long, then just select a 20 char substring from the field.
    2. Create a page bean property that returns a substring of the column's value to ensure that the value is not longer than the column width. I tested this by creating a table and droping the TRAVEL.PERSON data source on it.
    I then added this property to my page bean:
    private String shortJobTitle;
    * Getter for property shortJobTitle.
    * @return Value of property shortJobTitle.
    public String getShortJobTitle() {
    String jobTitle = (String) personDataProvider.getValue(
    "PERSON.JOBTITLE",
    tableRowGroup1.getRowKey());
    if (jobTitle != null && jobTitle.length() > 2) {
    jobTitle = jobTitle.substring(0, 2);
    return jobTitle;
    I then bound the column's text field to this property.
    Hope this helps,
    Chris

  • TableLayoutPanel row height adjustment for dynamic row

    Dear all, 
    i use a tablelayoutpanel to populate a calendar display. 
    As the row are generated dynamically during run time. 
    I would like to know how do i adjust the height in runtime for those row generated during runtime
    I notice after the table populated, the row count always to return one

    example :
    For i = 0 To table.Rows.Count - 1
    table.RowStyles.Add(New RowStyle(SizeType.Absolute, 100))
    Next
    This would set a 100 px height for each row.
    Nimzozo, from France.

  • Dynamically adjust table row height based on data in column

    Hi all,
    I'm using JDeveloper 11.1.1.5.0 and have a requirement for a table to adjust the height of its rows depending on the data in the columns. One of the columns in the table is a rich text description field and I have the 'rows' property set to 13. This field could have twenty lines of text/images or just one. The users would like the page to show all twenty lines of text without having to scroll but the table has the same height for all the rows (that I set to 13) and provides a scroll bar when the data exceeds this size. My users do not like to scroll, and want the height of each row to be determined by the data in it. I looked at a few options and also did a search online, but was unable to find anything to fulfill this requirement. Do you know of how I could change the height of each row in the table so that it fits the data that it holds?
    I have an example of my table at: <b>Table with Set Row Height</b>
    As you see, the picture has to be scrolled so that the whole picture is visible. The user requirement is to adjust the row height to show the full picture. Ideally the next two rows would shrink, but that would be a nice to have.
    Thanks in advance for any pointers or help.

    Hi Frank,
    Thank you for replying to my question, I truly appreciate your help.
    I tried to use the autoHeightRows to adjust the height of my rows but was unsuccessful. If I understand the autoHeightRows property correctly, this is used for setting the height of the whole table. If this is incorrect and it can be used for setting the height of individual rows in the table, please correct me. I have the 'Rows' property of the richTextEditor set to 13 and this is the height that I would like to make dynamic based on the data.
    My users requirement is for the height to be big enough for the data in each row of the table (the table has a description column and the height of each row should be determined by the data contained in it). I updated my <u><b>Screen Shot</b></u> to show the desired layout and what is currently being generated though ADF (http://www.flickr.com/photos/87583386@N05/) .
    I have three rows in the example (in actuality these are around 50) and the text in each row can vary. The users would like to see the full text/image in each row without having to scroll each row. Currently my table is within Panel Box, which is inside a PanelGroupLayout-Scroll which is in a PanelStretchLayout. I tried to put the table by itself with the autoHeightRow modifications you suggested but thsi did not help either. I am using JDeveloper 11.1.1.6.
    Is this possible with an ADF Table? If it is, is the autoHeight property the only one that I am setting incorrectly? If not, is there another component I can use to get the desired functionality? My users are very strict about this requirement and will not accept the application without this.
    Thanks,

  • Table Component and Row Height

    I am using XCelsius 4.5 and using the table component.  Is there anyway the row height on the table component can be linked to the Excel file?  It is not dynamically changing or wrapping text based on the amount of data that is imported in.

    Judging from the stack trace this has nothing to do with your variable row height. You are simply not respecting some array bounds (maybe your data array for the table model) when you insert the new row.
    In newRouteFare() do you fire a tableRowsInserted event? Or something similar? Check the rows passed into the Event object to see if you are exceeding the limits of the current table model.
    Thomas

  • Can we adjust ROW height in ALV report as like of Excel ?

    Dear all,
    Can we adjust ROW height in ALV report as like of Excel sheet ?
    Can we increase/decrease the row height in the output display ?
    How ?

    kps204020 wrote:
    Thanks a lot for your response.
    I've tried your proposal, but it has no affect. The report cells show all their content using as much lines as necessary for this.This is the default behaviour for HTML table data (tables and cells expand to fit their content).
    So I still have rows with lots of lines and rows with only a few lines mixed in my IR dependant on the cell content. Because some rows filling nearly the whole screen, it is difficult to get an overview with regard to adjacent rows.
    I'm using Application Express 4.1.1.00.23. with Theme 21. Scarlet and Firefox 17.0.1.Are all users using Firefox?
    Actually I'm working on my first APEX Solution for usage in my company and the customers demanding a solution for this topic . So I'm very keen to find a solution.
    I'm very much looking forward to your response.I've been involved with similar issues in the past. My first response is simple: Does this data have to be shown in the report? Can the offending column(s) be removed from the primary report? They will still be visible in the single row view, and the detail view if there is one.
    The second option is to create a detail view for the report with a structure that is better suited to the data involved, and make this the default view. (For an example of this, see the treatment of the PRODUCT_DESCRIPTION column in the detail view of the Products report in the Sample Database Application: click on the View Detail button on the Products page.)
    The third possibility is some kind of customization of the presentation of the data. This will involve using some combination of HTML/CSS/Dynamic Actions/Plug-ins/JavaScript that you may not be familiar with: do you have experience of these? To go down that route you need to describe in detail how you want to present the data, or what behaviour is required when the data is too long, and share an example of the report on apex.oracle.com that we can work with.

  • How to increase row height in table control?

    Hi experts,
    We have a push button in table control created using screen painter. Since this is a touch screen transaction, the default height is very small for the worker in the plant to click on a specific row, i would like to know if there is any way to increase the row height in the table control. There is no attribute in Screen painter for increasing row height in table control. I did try "import dynpro", hoping to increase the row height and export the dynpro, but that doesn't seem to have row height attributes. Any help in this regard is highly appreciated. Thanks,
    Raj

    Using a new technology means you have to recreate your screen: you may create an HTML using CL_DD_* classes (that's called "Dynamic Documents"). See [SAP Library - DD programming guide|http://help.sap.com/saphelp_nw2004s/helpdata/en/13/12284b019511d4a73e0000e83dd863/frameset.htm]. Demos are provided in SDYNAMICDOCUMENTS package. Or I think you may create web dynpro and define a CSS style to enlarge objects.
    If you don't want to create everything, maybe you can find out a workaround with GuiXT, for example creating a big button in each row (for example, with BUTTONSIZE, but don't know if it changes the height of rows but that's worth trying).
    Well, [Synactive documentation about table controls|http://www.synactive.com/docu_e/specials/tables.html] does not seem to allow that.
    Maybe you can move your question to the "scripting" forum and ask about how to do it with GuiXT...

Maybe you are looking for