Click to See Complete Forum and Search --> : How can you determine if a column used item wrap in a GridView?


goomyman
01-17-2006, 03:36 AM
I have a gridview object ( new for asp 2.0 ) and I am designing a page where I am trying to avoid forcing the user to scroll down the page at all.

I have limited the number of items to be displayed using Paging at 20 or so with no wrapping. However, if an item does wrapping that number needs to be lowered by 1 since it now takes up 2 rows.

How can I tell if an item wraps at run time so that I can decrement by 1. I cant check for string length because length is relavent to the size of the characters. For instance WWWWW is longer than lllll. Is there a way to do this?

http://www.vgexchange.com is the site if anyone wants to check it out or even help i could use a ton especially in design and graphics.

lmf232s
01-17-2006, 03:12 PM
Well why this is not the answer to your problem it may help a bit.
Im not sure if you are having a problem w/ 1 field or w/ multiple fields.
If its 1 field then this might work. What i have done in cases such as your is create
a link <a href="#" tooltip="?">Detials</a> and i set the tool tip to the text of that field.
That way it does not take up another row. Although it does not display the user is able to hover over the link and read the tooltip.

goomyman
01-18-2006, 11:56 AM
That would work. Thanks for the idea. I dont know if I am willing to sacrifice looks for that though.

I would rather just let the row take up 2 rows after it wraps and lower the page number. So for instance, if I allow 20 rows, but 5 of those wrap, I will now have a grid that takes up 25 rows, but if I lower the pagesize for each row that wraps, it will still only take up 20 rows.

Bullschmidt
01-23-2006, 08:30 PM
And you might want to always show only the first 20 characters of a field perhaps and put ... after if it's more than 20 (just another idea)...


Function jpsvbParagraphAbbr(pvarFld, pintLen)
' Purpose: Paragraph abbreviate.
' Remarks: Doesn't chop up the final word. Usually puts ... after.

' Dim var.
Dim varFld
Dim strChar
Dim intFinalWhiteSpaceBlockStartPos
Dim intFinalWhiteSpaceBlockEndPos
Dim I

' Set var.
varFld = pvarFld

' Quick exit if blank.
If IsNull(varFld) Or (Len(varFld) = 0) Then
jpsvbParagraphAbbr = ""
Exit Function
End If

' Convert to string.
varFld = CStr(varFld)

' Quick exit if not too long.
If Len(varFld) <= pintLen Then
jpsvbParagraphAbbr = varFld
Exit Function
End If

' Truncate to 1 more char than the needed len.
varFld = Left(varFld, pintLen + 1)

' Init.
intFinalWhiteSpaceBlockStartPos = 0

' Go back char by char to find the final white space block start pos.
' (There could be several white spaces in a row.)
' (I.e. if desired len is 15, find pos of the 1st space after the p in "Can't stop now.")
For I = pintLen + 1 To 1 Step -1
' Set var.
strChar = Mid(varFld, I, 1)

' If space, tab, CR, or LF.
If (strChar = " ") Or (strChar = Chr(9)) Or (strChar = Chr(13)) Or (strChar = Chr(10)) Then
intFinalWhiteSpaceBlockStartPos = I
Else
If intFinalWhiteSpaceBlockStartPos > 0 Then
Exit For
End If
End If
Next ' Next I.

' Keep the proper num of chars from the left.
If intFinalWhiteSpaceBlockStartPos > 0 Then
' Truncate to just before final white space.
varFld = Left(varFld, intFinalWhiteSpaceBlockStartPos - 1)
Else
' Keep the orig up to the desired len (i.e. drop the temp addtl char).
varFld = Left(varFld, pintLen)
End If

' Add ... at end.
' (If varFld already ends in ., then only add two more .'s)
If Right(varFld, 1) = "." Then
varFld = varFld & ".."
Else
varFld = varFld & "..."
End If

' Return val.
jpsvbParagraphAbbr = varFld
End Function