create dynamic columns

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default create dynamic columns

    Any one knows how to display sentence in 3 colums in coldfusion .

    Thank you!
    cornelio Guest

  2. Similar Questions and Discussions

    1. 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...
    2. 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,...
    3. 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...
    4. 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...
    5. 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...
  3. #2

    Default Re: create dynamic columns

    Use a TABLE and put the sentences into their own TD cells?
    zoeski80 Guest

  4. #3

    Default 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

  5. #4

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139