ColdFusion:根据条件突出显示 CFGrid 中的行?

发布于 2024-10-09 04:41:44 字数 126 浏览 0 评论 0原文

我正在 Coldfusion 中构建一个应用程序,基本上它是一个跟踪会员资格何时到期的模块。我正在建立所有成员的索引,我想使用 cfgrid。

有没有办法指定在会员资格到期后 x 天内该行突出显示?

谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

短暂陪伴 2024-10-16 04:41:44

为此,您可能需要自己编写一些 JavaScript。首先通过 ColdFusion.Grid.getGridObject 获取 ExtJS 对象,然后查看 ExtJS 文档 (http://dev.sencha.com/deploy/dev/docs/) 以了解可以做什么。

另一种选择是在 ColdFusion 中进行计算并向网格添加另一列。

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.

溺孤伤于心 2024-10-16 04:41:44

是的

<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>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文