2 Replies Latest reply on Sep 4, 2007 6:54 AM by pelican

    comparing columns within cfgrid

    pelican
      I have 2 queries that populate a third query using cfloop and querynew. The third query, "table1", works just fine. But I am using a java format cfgrid to output "table1". I want to highlight, change color, or something, when the value in one column's row does not match another column's row. Is that possible? How?
        • 1. Re: comparing columns within cfgrid
          Dinghus Level 1
          When you say that the 2 queries "populate" a 3rd query are you really meaning to say that you have a query of queries or that your 1st 2 are creating temp tables?
          Queries do not "populate" anything. You can populate a table from a query.

          Now if you have 2 queries and you want to compare the values, then you will have to put the data into lists or some such where you can actually do a comparison.

          Like
          <cfif group1[1] EQ group2[1]>

          Along those lines.
          • 2. Re: comparing columns within cfgrid
            pelican Level 1
            Here's my code:

            <cfquery name="qrytl2000" datasource="libl">
            SELECT #choose2# FROM tldb70.drmst WHERE dracpy = 05 AND drasts IN (#preservesinglequotes(status2)#) AND (DRASID = '100' OR DRASID = '300')
            AND dradsp IN (99981,99982,99991,99992,99993,99994)
            </cfquery>

            <cfset table1 = querynew("tl2000drivercode,tl2000drivername,tl2000fleet,tl2000status,sqldrivercode,sqldri vername,sqlfleet,sqlstatus","varchar,varchar,integer,varchar,varchar,varchar,integer,varch ar")>
            <cfloop query="qrytl2000">
            <cfset addrow = queryaddrow(table1,1)>
            <cfset driverset = querysetcell(table1,"tl2000drivercode",qrytl2000.dradrv)>
            <cfset nameset = querysetcell(table1,"tl2000drivername",qrytl2000.dranam)>
            <cfquery name="qrysql" datasource="timeoff">
            SELECT #choose# FROM dbo.log_status WHERE drivercode = '#trim(qrytl2000.dradrv)#'
            </cfquery>
            <cfset driverset2 = querysetcell(table1,"sqldrivercode",qrysql.drivercode)>
            <cfset nameset2 = querysetcell(table1,"sqldrivername",qrysql.drivername)>
            <!---This section is for the Fleet number from TL2000. JP--->
            <cfif isDefined("qrytl2000.dradsp") AND #qrytl2000.dradsp# NEQ "">
            <cfset fleetset = querysetcell(table1,"tl2000fleet",qrytl2000.dradsp)>
            <cfset fleetset2 = querysetcell(table1,"sqlfleet",qrysql.fleet)>
            <cfelse>
            <cfset fleetset = querysetcell(table1,"tl2000fleet","")>
            <cfset fleetset2 = querysetcell(table1,"sqlfleet","")>
            </cfif>
            <!---This section is for the Driving Status from TL2000. JP--->
            <cfif isDefined("qrytl2000.drasts") AND #qrytl2000.drasts# NEQ "">
            <cfset statusset = querysetcell(table1,"tl2000status",qrytl2000.drasts)>
            <cfset statusset2 = querysetcell(table1,"sqlstatus",qrysql.drivingstatus)>
            <cfelse>
            <cfset statusset = querysetcell(table1,"tl2000status","")>
            <cfset statusset2 = querysetcell(table1,"sqlstatus","")>
            </cfif>
            </cfloop>


            <cfformgroup type="horizontal">
            <cfgrid name="details" query="table1" format="applet" colheaderbold="yes" colheaderalign="center" rowheaders="no" griddataalign="center" height="650" width="1200">
            <cfif #table1.sqlstatus# NEQ #table1.tl2000status#>
            <cfgridcolumn header="TL2000 PTO Code" name="tl2000drivercode" bgcolor="##FF3333" dataalign="left" width="120">
            <cfgridcolumn header="Database PTO Code" name="sqldrivercode" bgcolor="##FF3333" dataalign="left" width="140">
            <cfif isDefined("URL.drivername") AND #URL.drivername# EQ "drivername">
            <cfgridcolumn header="TL2000 PTO Name" name="tl2000drivername" bgcolor="##FF3333" dataalign="left" width="200">
            <cfgridcolumn header="Database PTO Name" name="sqldrivername" bgcolor="##FF3333" dataalign="left" width="200">
            </cfif>
            <cfif isDefined("URL.fleet") AND #URL.fleet# EQ "fleet">
            <cfgridcolumn header="TL2000 Fleet" name="tl2000fleet" bgcolor="##FF3333" width="100">
            <cfgridcolumn header="Database Fleet" name="sqlfleet" bgcolor="##FF3333" width="100">
            </cfif>
            <cfif isDefined("URL.status") AND #URL.status# EQ "status">
            <cfgridcolumn header="TL2000 PTO Status" name="tl2000status" bgcolor="##FF3333" width="140">
            <cfgridcolumn header="Database PTO Status" name="sqlstatus" bgcolor="##FF3333" width="140">
            </cfif>
            <cfelse>
            <cfgridcolumn header="TL2000 PTO Code" name="tl2000drivercode" dataalign="left" width="120">
            <cfgridcolumn header="Database PTO Code" name="sqldrivercode" dataalign="left" width="140">
            <cfif isDefined("URL.drivername") AND #URL.drivername# EQ "drivername">
            <cfgridcolumn header="TL2000 PTO Name" name="tl2000drivername" dataalign="left" width="200">
            <cfgridcolumn header="Database PTO Name" name="sqldrivername" dataalign="left" width="200">
            </cfif>
            <cfif isDefined("URL.fleet") AND #URL.fleet# EQ "fleet">
            <cfgridcolumn header="TL2000 Fleet" name="tl2000fleet" width="100">
            <cfgridcolumn header="Database Fleet" name="sqlfleet" width="100">
            </cfif>
            <cfif isDefined("URL.status") AND #URL.status# EQ "status">
            <cfgridcolumn header="TL2000 PTO Status" name="tl2000status" width="140">
            <cfgridcolumn header="Database PTO Status" name="sqlstatus" width="140">
            </cfif>
            </cfif>
            </cfgrid>
            </cfformgroup>


            How can I compare the individual rows of data between the columns; ie, tl2000drivercode compared with sqldrivercode to see if they match or not?