Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Dynamic cfgridcolumn name?

New Here ,
Dec 01, 2008 Dec 01, 2008
Hi There,

I'm having a query which returns different columns based on the input. I'm trying to get the cfgridcolumn name dynamic. For example, in below code column name ABC has been hardcoded.

<cfgrid bindonload="yes" bind="cfc:xyz.entityList({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})">
<cfgridcolumn name="ABC" header="ABC"/>
</cfgrid>

Is there a way were we can mention the columnname as a variable? Something similor to:

<cfgrid bindonload="yes" bind="cfc:xyz.entityList({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})">
<cfloop list="#entityList.ColumnList#" index = "index">
<cfgridcolumn name="ABC" header="ABC"/>
</cfloop>
</cfgrid>

Any help would be greatly appeciated.

Many thanks
TOPICS
Getting started
615
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Dec 01, 2008 Dec 01, 2008
Convert your columnlist to an array like,

<cfset colList = ArrayToList(your_query.getColumnList())>


Then you can assign it to a gridcolumn as,

<cfloop list="#colList#" index="i">
<cfgridcolumn name="#i#" header="#i#" headeralign="left" dataalign="left" bold="yes" italic="no" select="yes" display="yes" headerbold="no" headeritalic="yes">
</cfloop>


HTH
Translate
Advocate ,
Dec 01, 2008 Dec 01, 2008
Convert your columnlist to an array like,

<cfset colList = ArrayToList(your_query.getColumnList())>


Then you can assign it to a gridcolumn as,

<cfloop list="#colList#" index="i">
<cfgridcolumn name="#i#" header="#i#" headeralign="left" dataalign="left" bold="yes" italic="no" select="yes" display="yes" headerbold="no" headeritalic="yes">
</cfloop>


HTH
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 01, 2008 Dec 01, 2008
LATEST
That made my life easier. Thanks a lot for your time and effort.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources