ColdFusion: Highlight Row in CFGrid based on condition?

I'm building an app in Coldfusion, basically it's a module that tracks when memberships expire. I'm building an index of all members, I am wanting to use cfgrid.

Is there a way to specificy that within x days of the membership expiring for the row to get highlighted?

Thanks!

Answers


To do this you would probably have to write some JavaScript yourself. First get the ExtJS object via ColdFusion.Grid.getGridObject then look at the ExtJS docs (http://dev.sencha.com/deploy/dev/docs/) to see what can be done.

Another option would be to do the calculation in ColdFusion and add another column to the grid.


Yes

<cfajaximport/>
<html>

<head>
<script>

myf = function(data,cellmd,record,row,col,store) {
    // hard code a date to check against "13 Jan 2011"
    // note 0 based month index
    var today = new Date(2011,0,13);
    if(data < today) {
        //before displaying format the date
        var curr_date = data.getDate();
        var curr_month = data.getMonth();
        //javascript has month as a 0 based index so add one
        curr_month++;
        var curr_year = data.getFullYear();
        return "<span style='color:red;font-weight:bold;'>" + curr_date + "-" + curr_month + "-" + curr_year + "</span>";
    }
    else {
        //before displaying format the date
        var curr_date = data.getDate();
        var curr_month = data.getMonth();
        //javascript has month as a 0 based index so add one
        curr_month++;
        var curr_year = data.getFullYear();
        return curr_date + "-" + curr_month + "-" + curr_year;
    }
}
testgrid = function() {
    mygrid = ColdFusion.Grid.getGridObject('data');
    cm = mygrid.getColumnModel();
    // render the first column (0 based index) using the myf function above 
    cm.setRenderer(0,myf);
    mygrid.reconfigure(mygrid.getDataSource(),cm);
}
</script>
</head>

<body>

<!--- create a hard coded query for testing --->
<cfset data = queryNew("expiryDate,member")>
<cfloop from=1 to=31 index="i">
    <cfset expiryDate = createDate(2011,1,i)>
    <cfset member = "Member #i#">
    <cfset queryAddRow(data)>
    <cfset querySetCell(data, "expiryDate", expiryDate, i)>
    <cfset querySetCell(data, "member", member, i)>
</cfloop>

<cfform name="test">
<cfgrid autowidth="true" name="data" format="html" query="data" width="600">
   <cfgridcolumn name="expiryDate" header="Expiry Date">
   <cfgridcolumn name="member" header="Member">
</cfgrid>
</cfform>

<cfset ajaxOnLoad("testgrid")>
</body>
</html>

Need Your Help

omitting the for loops in matlab

arrays matlab for-loop vectorization

I am going to compute the following equation in which there are four different variables. Is there any possible way to omit the for loops for computing this equation?

Cannot connect to GIT from jenkins

git jenkins

I have run Jenkins on AIX with:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.