Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
cornelio #1
create dynamic columns
Any one knows how to display sentence in 3 colums in coldfusion .
Thank you!
cornelio Guest
-
Create Columns at run time
if you place a datagrid on a form and then, in Property builder, check the box saying Create Columns at run time. An then do a SQL Select into a... -
How To Create Columns?
Im using CF6.1 and Access. I want to run a query or somehting that will allow me to create columns in access. Im designing a setup page for my app,... -
Dynamic Columns
I am working on a query builder, where I am trying to let a user specify any combination of several checkboxes, which are then passed to a variable... -
Datagrid Dynamic Columns
This is my problem I have a data grid with about twenty columns, I have a dropdown list that allows the user to select the view they want for the... -
Dynamic columns creation
Hi. I have a stored procedure that among other things returns a column with values that will be used to compose a temporary table. The number of... -
zoeski80 #2
Re: create dynamic columns
Use a TABLE and put the sentences into their own TD cells?
zoeski80 Guest
-
cornelio #3
Re: create dynamic columns
what i want is divide my sentence in 3 columns dynamically... example : i have
a sentence let say more than 10 paragrah place in a variable and i want to
display this in 3 columns. -- i can divide the sentence by using
len(mySentence)/number of rows, but my problem is i cut the last work not
correcly. This is a testing ng This is a testing This is a testing
This is a testing This is a testing This This is a testing This is a
testing is a testing This is a This is a testing This is a testi
testing This is a testing This is a testing look at the last word in first
column and the continuation in second column. Thanks!
cornelio Guest
-
zoeski80 #4
Re: create dynamic columns
Hi Conelio
I don't fully understand what you're doing, your sample didn't have distinct
columns shown.
Have attached some code, hope it helps.
- Zoe
<cfset thisSentence = "This is a test sentence 1. This is a test sentence 2.
This is a test sentence 3. This is a test sentence 4. This is a test sentence
5. This is a test sentence 6. This is a test sentence 7. This is a test
sentence 8. This is a test sentence 9. This is a test sentence 10. This is a
test sentence 11.">
<CFSET numberOfColumns = 3>
<!--- if you want to have the same number of words in each column --->
<CFSET numberWordsInSentence = ListLen(thisSentence, " ")>
<CFSET numberWordsPerColumn = ceiling(numberWordsInSentence / numberOfColumns)>
<CFOUTPUT>
<TABLE BORDER=1>
<TR>
<CFLOOP FROM="1" TO="#numberOfColumns#" INDEX="ColumnNumber">
<CFSET wordsToAdd = (ColumnNumber - 1) * numberWordsPerColumn>
<TD>
<CFLOOP FROM="1" TO="#numberWordsPerColumn#" INDEX="this">
<CFSET thisWord = wordsToAdd + this>
<CFIF ListLen(thisSentence, " ") GTE thisWord>
#ListGetAt(thisSentence, thisWord, " ")#
</CFIF>
</CFLOOP>
</TD>
</CFLOOP>
</TR>
</TABLE>
</CFOUTPUT>
<BR><BR><BR><BR>
<!--- if you want to keep whole sentences together --->
<CFSET sentenceSeparator = ".">
<CFSET numberWordsInSentence = ListLen(thisSentence, sentenceSeparator)>
<CFSET numberWordsPerColumn = ceiling(numberWordsInSentence / numberOfColumns)>
<CFOUTPUT>
<TABLE BORDER=1>
<TR>
<CFLOOP FROM="1" TO="#numberOfColumns#" INDEX="ColumnNumber">
<CFSET wordsToAdd = (ColumnNumber - 1) * numberWordsPerColumn>
<TD>
<CFLOOP FROM="1" TO="#numberWordsPerColumn#" INDEX="this">
<CFSET thisWord = wordsToAdd + this>
<CFIF ListLen(thisSentence, sentenceSeparator) GTE thisWord>
#ListGetAt(thisSentence, thisWord, sentenceSeparator)##sentenceSeparator#
</CFIF>
</CFLOOP>
</TD>
</CFLOOP>
</TR>
</TABLE>
</CFOUTPUT>
<BR><BR><BR><BR>
<!--- if you want to have the same number of CHARACTERS in each column --->
<CFSET numberCharactersPerColumn = ceiling(Len(thisSentence) /
numberOfColumns)>
<CFOUTPUT>
<TABLE BORDER=1>
<TR>
<CFLOOP FROM="1" TO="#numberOfColumns#" INDEX="ColumnNumber">
<CFSET thisStart = (ColumnNumber - 1) * numberCharactersPerColumn + 1>
<TD>
<CFIF Len(thisSentence) GTE thisWord>
#Mid(thisSentence, thisStart, numberCharactersPerColumn)#
</CFIF>
</TD>
</CFLOOP>
</TR>
</TABLE>
</CFOUTPUT>
zoeski80 Guest



Reply With Quote

