Coldfusion Grid Fontsize - coldfusion

I am having trouble changing the font size of the text in the columns. I have used attribute fontsize and it does not work.
<cfform name="mainF">
<cfgrid name="record" query="getRecords" format="html">
<cfgridcolumn name="act" FONTSIZE="300" bold="yes" >
<cfgridcolumn name="sub" FONTSIZE="15">
<cfgridcolumn name="Mon" FONTSIZE="15" DATAALIGN="CENTER">
<cfgridcolumn name="date_of" fontsize="15" DATAALIGN="CENTER">
<cfgridcolumn name="Desc" width="510" display="yes" fontsize="15">
</cfgrid>
</cfform>

Yep, I never could get that to work. I had to do some digging, and ended up using CSS.
/* should set the whole grid */
.x-grid3{
font:Consolas;
}
/* grid title area */
.x-panel-header{
font-size:18px;
font:Consolas;
}
/* column headers */
.x-grid3-hd-inner{
font-size:12px;
}
/* cells with data */
.x-grid3-cell-inner{
font-size:14px;
}
I used 'Inspect Element with Firebug' to find the different areas. The grid itself is built (roughly) with a combination of table elements for the structure, and div elements for data (divs area used for other things too).
Good Luck

Related

SpreadsheetFormatColumn() Right Border

When I run this code:
<cfscript>
flinstones = "fred,wilma,pebbles";
Workbook = Spreadsheetnew("Workbook");
for (i = 1; i lte listlen(flinstones); i ++) {
ThisFlinstone = ListGetAt(Flinstones, i);
if (ThisFlinstone == "wilma")
SpreadSheetAddRow(Workbook, "#ThisFlinstone#,barney");
else
SpreadSheetAddRow(Workbook, ThisFlinstone);
}
Format = {};
format.rightborder = "thin";
SpreadsheetFormatColumn(WorkBook, Format, 2);
MYfile = "d:\dw\dwtest\dan\abc.xls";
writedump(format);
</cfscript>
<cfspreadsheet action="write" filename="#MYFile#" name="Workbook"
sheet=1 sheetname="flinstones" overwrite=true>
I expect to see a worksheet with three rows. The second row will have two columns, with wilma and barney in the cells. So far, I see what I expect. I also expect to see Column B with a right hand border. I actually see cell B2 with a right hand border.
If I change this:
SpreadSheetAddRow(Workbook, ThisFlinstone);
to this
SpreadSheetAddRow(Workbook, "#ThisFlinstone#, ");
I see a right hand border for the first three rows of Column B.
Is there a way to have the right hand border apply to all of Column B?
Update:
As Dan mentioned in the comments, I misread the question. To clarify, adding a border to an entire column was not supported by POI last I checked. The only way to make the border appear on the entire column is to populate every single cell in that column first. Either by setting a value explicitly or using SpreadsheetFormatCellRange(sheet, format, 1, 2, maxRow, 2) with the maximum row number. While this does work, I would not recommend it as it has some undesirable side effects.
Is there a way to have the right hand border apply to all of Column B?
Short answer:
Yes, by doing what you already discovered: give all of the cells ie B1, B2 and B3 a value first. Even if it is just a blank or an empty string. This will create a border on all three cells.
Update 1: If you are using CF 9.0.1, another option is SpreadsheetFormatCellRange. Unlike most spreadsheet functions, it automatically creates non-existent cells first:
<cfset SpreadsheetFormatCellRange(Workbook, Format, 1, 2, 3, 2)>
Longer answer:
To apply a format, you need what POI calls a Cell object. When you create a new worksheet, it is completely blank, with no "cells" whatsoever. In most cases, CF only creates a Cell object when you set a value with one of the various functions ie SpreadSheetSetCellValue, SpreadSheetAddRow, etcetera. (See example below). Your original code only sets a one value in Column B. Hence it only creates a single Cell, ie B2. SpreadsheetFormatColumn only formats existing cells, that is why the border is only visible in B2.
<!--- blank sheet with no CELLS --->
<cfset Workbook = Spreadsheetnew() />
<cfset SpreadSheetWrite(Workbook, "c:/test.xls", true) />
<cfspreadsheet action="read" src="c:/test.xls" query="qValues" />
<cfdump var="#qValues#" label="No cells exist yet" />
<!--- setting one value, creates one CELL --->
<cfset Workbook = Spreadsheetnew() />
<cfset SpreadSheetAddRow(Workbook, "Fred") />
<cfset SpreadSheetWrite(Workbook, "c:/test.xls", true) />
<cfspreadsheet action="read" src="c:/test.xls" query="qValues" />
<cfdump var="#qValues#" label="Creates a single cell" />
<!--- setting two values, creates two CELL's --->
<cfset Workbook = Spreadsheetnew() />
<cfset SpreadSheetAddRow(Workbook, "Fred, ") />
<cfset SpreadSheetWrite(Workbook, "c:/test.xls", true) />
<cfspreadsheet action="read" src="c:/test.xls" query="qValues" />
<cfdump var="#qValues#" label="Creates two cells" />

ColdFusion: Can you pull out a unique record from a query using recordCount?

It's a bit of tricky question, however, my page for most rated bands displays the band logos in order of how high they have been rated. My only problem is i want to count through the records by using a cfloop from 1 to 10 and because it is split in to two columns, have one counting 1 through to 9 and the other 2 through to 10, each of them with steps of two.
Can anybody help me with this? If i've confused just mention it and ill try to clarify exactly what i mean.
<DIV class="community_middle">
<cfoutput query="top10MostRated">
<cfloop from="2" to="10" index="i" step="2">
<DIV class="communityContent">
#chr(i)#
<IMG src="logo/#top10MostRated.Logo#" alt="#top10MostRated.Name#" width="100%" height="100%"></IMG>
</DIV>
<BR/>
</cfloop>
</cfoutput>
</DIV>
If you're looking to do odd/even lists separately, then you can use the currentrow property of the query combined with the modulo operator (%) to work out if the row is odd or even:
<cfloop query="topBands>
<cfif topBands.currentRow % 2 = 1>
<!--- do your odd number output here --->
</cfif>
</cfloop>
<cfloop query="topBands>
<cfif topBands.currentRow % 2 = 0>
<!--- do your even number output here --->
</cfif>
</cfloop>
I think these answers address your side-by-side part of your question but does not explain the "same image" issue. Their code is written correctly but does not explain the reason.
Your code:
<IMG src="logo/#top10MostRated.Logo#"
alt="#top10MostRated.Name#"
width="100%" height="100%"></IMG>
... would be fine if you were only inside a <cfloop query = "top10MostRated"> or <cfoutput query = "top10MostRated"> block. The reason is because inside these types of blocks CF is smart enough to know you want the data for the current row. It would be the same as:
<IMG src="logo/#top10MostRated.Logo[top10MostRated.currentRow]#"
alt="#top10MostRated.Name[top10MostRated.currentRow]#"
width="100%" height="100%" />
Because you're nesting the to/from cfloop inside a <cfoutput query = ""> block, you are getting unexpected results. Your existing code is always asking for the record provided by your outer loop. Hence you see the same image 5 times. (using any of the fine examples provided will help you get out of this) but, you can remove the query from your cfoutput and simply ask CF to show you the value for the correct row in your loop using your index (you set your index to "i") so the below would show you the image that corresponds to your loop.
<IMG src="logo/#top10MostRated.Logo[i]#"
alt="#top10MostRated.Name[i]#"
width="100%" height="100%" />
It sounds like what you'd like to get is a collection of even-numbered records and a collection of odd-numbered records. In Coldfusion 10 or Railo 4, you can use groupBy() from Underscore.cfc to split up your query result into manageable sub-sets, like so:
_ = new Underscore();// instantiate the library
groupedBands = _.groupBy(topBands, function (val, index) {
return index % 2 ? "odd" : "even";
});
This returns a struct with two elements odd and even, each containing an array of records which are odd or even. Example result:
{
odd: [{name: "Band one"}, {name: "Band three"}],
even: [{name: "Band two"}, {name: "Band four"}]
}
Splitting your results into logical sub-sets makes the code more readable:
<cfoutput>
<cfloop from="1" to="5" index="i">
<div class="left">#groupedBands.odd[i].name#</div>
<div class="right">#groupedBands.even[i].name#</div>
</cfloop>
</cfoutput>
You'll also be able to use those sub-sets in other places on your page if you need to.
Note: I wrote Underscore.cfc
Ben Nadel has a post exactly for this. Link here
A breakdown for this is
<cfloop query="top10MostRated">
<cfif top10MostRated.CurrentRow MOD 2>
<!--- Add to the "odd list" --->
<cfelse>
<!--- Add the record to the "even list" --->
</cfif>
</cfloop>
Then you'll have 2 lists oddList and evenList. Then it's just a matter of displaying them.
I'd do it a different way. The objective is to have records 1 and 2 side by side and I don't see that in #barnyr's answer.
<cfoutput>
<cfloop from="2" to="topbands.recordcount + 1" index = "i" step="2">
#topbands.fieldname[i-1]#
<cfif i lte topbands.recordcount>
#topbands.fieldname[i]# <br />
</cfif>
</cfloop>
</cfoutput>

limit x axis for cfchart

I would like to limit the x-axis of my chart that is created by cfchart. I see the attribute scaleFrom and scaleTo that limit the y-axis, but I see nothing that limits the x-axis.
Also, I saw a similar question here:
ColdFusion Chart x-axis label limits
but neither of the answers were appropriate. ScaleMin and ScaleMax do not exists as far as I can tell and the other answer is more complicated than what I'd like to do.
The scaleMin and scaleMax attributes Saul mentioned are only available when using a custom style. Note, using type "scale" means your xAxis values must be numeric. If you want to use strings, you will probably need to use Ben's approach instead.
Here is a quick example that creates a chart with 24 points on the xAxis. Even though the query only contains the first six (6) points.
<!--- bare bones style --->
<cfsavecontent variable="style">
<?xml version="1.0" encoding="UTF-8"?>
<frameChart is3D="false" isInterpolated="true">
<frame xDepth="3" yDepth="1" />
<xAxis type="Scale" scaleMin="0" scaleMax="24" labelCount="25" isBucketed="false" />
</frameChart>
</cfsavecontent>
<!--- sample query --->
<cfset qry = queryNew("")>
<cfset queryAddColumn(qry, "xValue", listToArray("1,2,3,4,5,6"))>
<cfset queryAddColumn(qry, "yValue", listToArray("30,15,22,14,45,5"))>
<!--- chart code --->
<cfchart format="jpg" style="#style#" width="600">
<cfchartseries type="line"
markerstyle="circle"
query="qry"
itemColumn="xValue"
valueColumn="yValue" />
</cfchart>

Infragistics columnfilter

In my application i have used WebDataGrid Infragistics control. I have total 5 columns(Status,CandidateName,WorkOrderId,VenderName,Rate) in this grid. I needed to apply filter on 2 columns only i.e; Status and CandidateName. I have explicitly write code to set filter only in 2 columns. Below is my code. But, the problem is, Filter is applying on all the 5 columns regardless of setting the filter explicitly.
<ColumnFilters>
<ig:ColumnFilter ColumnKey="Status">
<ConditionWrapper>
<ig:RuleTextNode Rule="Contains" />
</ConditionWrapper>
</ig:ColumnFilter>
<ig:ColumnFilter ColumnKey="CandidateName">
<ConditionWrapper>
<ig:RuleTextNode Rule="Contains" />
</ConditionWrapper>
</ig:ColumnFilter>
</ColumnFilters>
Please any one can tell me how to apply filter only on specific columns defined explicitly.
Thanks in Advance !!!!
You should be able to disable the other columns by setting Enabled=false as follows:
<Behaviors>
<ig:Filtering>
<ColumnSettings>
<ig:ColumnFilteringSetting ColumnKey="WorkOrderId" Enabled="false" />
<ig:ColumnFilteringSetting ColumnKey="VenderName" Enabled="false" />
<ig:ColumnFilteringSetting ColumnKey="Rate" Enabled="false" />
</ColumnSettings>
</ig:Filtering>
</Behaviors>

CFCHART: reverse Y-axis ordering

I mean that MIN should be on top and MAX on X-axis.
This needed to make chart more intuitive to read and related to object ranking, when 1st place is "better" than 3rd. That's why it'd be better to look this way:
(source: xantea.net) =>
(source: xantea.net)
This can be done using custom XML. I ran the Chart Designer (cfinstall/charting/webcharts.bar (or .sh) and simply worked with the YAxis setting. There is an isReversed setting which does what you want. Consider this code:
<cfset q2 = queryNew("year,employees","integer,integer")>
<!--- generate random sales data --->
<cfloop index="y" from="1994" to="1998">
<cfscript>
queryAddRow(q2);
querySetCell(q2, "year", y);
querySetCell(q2, "employees", randRange(2,8));
</cfscript>
</cfloop>
<cfsavecontent variable="chartxml">
<?xml version="1.0" encoding="UTF-8"?>
<frameChart is3D="false">
<yAxis isReversed="true">
</yAxis>
</frameChart>
</cfsavecontent>
<cfchart chartWidth="400" chartHeight="400" title="Sales" font="arial" style="#chartxml#">
<cfchartseries type="line" query="q2" itemColumn="year" valueColumn="employees" seriesLabel="Employees" />
</cfchart>
The query on top was just used for testing. The XML came from the chart designer. I removed everything but the yAxis stuff that used isReverse. Lastly, note how I specify style in the chart tag.