Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

(Help please) Adding an ad icon to my parent and child list

Posted on 2014-03-25
8
Medium Priority
?
255 Views
Last Modified: 2014-03-25
Hi,

I have a parent and child list that I need to add an (ad icon) to the list.

the output should look just like in the image.  If the record is a child the ad icon should be added to the end of the list. If the record is a parent the ad icon should be added right after it.  

I need your help please.

Thanks,
Lulu



<cfif val(QSearchResult.ParentIssueID)> 
 <!-- //Child Row -->
 <tr class="bg2row">
   <td style="padding-left:20px;">#QSearchResult.issueID#</td>
 <td>#QSearchResult.ticketNumber#</td>
 <td>#QSearchResult.Category#</td>
 <td>#QSearchResult.TitleOfIssue#</td>
 <td>#QSearchResult.Status#</td>
  <td>#DateFormat(QSearchResult.DateCreated, "m/d/yyyy")#</td>
    <td><a href="LogEntry.cfm?EID=#QSearchResult.issueID#"><img src="images/edit.png" alt="Edit Sub Issue" /></a>
    <img src="images/view.png" alt="View Sub Issue" />
    </td>
    </tr>  
 <cfelse>
<!-- //Parent Row -->
 <tr class="bgrow">
   <td style="font-weight:bold;padding-left:5px;">#QSearchResult.issueID#</td>
 <td style="font-weight:bold;">#QSearchResult.TicketNumber#</td>
 <td style="font-weight:bold;">#QSearchResult.Category#</td>
 <td style="font-weight:bold;">#QSearchResult.TitleOfIssue#</td>
 <td style="font-weight:bold;">#QSearchResult.Status#</td>
  <td style="font-weight:bold;">#DateFormat(QSearchResult.DateCreated, "m/d/yyyy")#</td>
  <td style="color:dark blue;"><a href="LogEntry.cfm?EID=#QSearchResult.issueID#"><img src="images/edit.png" alt="Edit Sub Issue" /></a>
  <img src="images/view.png" alt="View Sub Issue" />
  </td>
  </tr>
  
 </cfif>

Open in new window




 <tr class="bg2row">
    <td colspan="6" style="text-align:right;">
      <a href="LogEntry.cfm?AID=#QSearchResult.ParentIssueID#"><img src="images/add.png" alt="Add Sub Issue" /></a>
    </td>
    <td>
    </td>
    </tr>

Open in new window


ad
0
Comment
Question by:lulu50
  • 5
  • 3
8 Comments
 
LVL 39

Accepted Solution

by:
gdemaria earned 2000 total points
ID: 39953359
Hi Lulu,
I know it seems complex to figure out the pattern of when to display the icon, after a parent if no children (how do you know if there are children?)  and after the last child, (how do you know if its the last child?)

But think of it this way.   The icon appears BEFORE every parent record.   So, that's a much easier way to think of it when coding.  Before drawing a parent record, you need to show this Add Icon from the previous set of records regardless of whether there are children or not.

The exception is, that you don't want to show it for the first parent record (because there is nothing before it).    The only challenge then is to know what the ID is of the ID before the parent you are drawing.  So we will just put in a variable to remember the previous ID.

Check this out...

<cfif val(QSearchResult.ParentIssueID)> 
 <!-- //Child Row -->
 <tr class="bg2row">
    <td style="padding-left:20px;">#QSearchResult.issueID#</td>
    <td>#QSearchResult.ticketNumber#</td>
    <td>#QSearchResult.Category#</td>
    <td>#QSearchResult.TitleOfIssue#</td>
    <td>#QSearchResult.Status#</td>
    <td>#DateFormat(QSearchResult.DateCreated, "m/d/yyyy")#</td>
    <td>
	  <a href="LogEntry.cfm?EID=#QSearchResult.issueID#"><img src="images/edit.png" alt="Edit Sub Issue" /></a>
      <img src="images/view.png" alt="View Sub Issue" />
    </td>
  </tr>  
<cfelse>
<!-- //Parent Row -->
 <cfif QSearchResult.currentRow gt 1 and val(previousParentIssueID)>
 <tr>
   <td colspan="6">&nbsp;</td>
   <td><a href="AddChild.cfm?EID=#previousParentIssueID#"><img src="images/AddChild.png" alt="Add Child" /></a>
 </tr>
 </cfif>
 <tr class="bgrow">
	 <td style="font-weight:bold;padding-left:5px;">#QSearchResult.issueID#</td>
	 <td style="font-weight:bold;">#QSearchResult.TicketNumber#</td>
	 <td style="font-weight:bold;">#QSearchResult.Category#</td>
	 <td style="font-weight:bold;">#QSearchResult.TitleOfIssue#</td>
	 <td style="font-weight:bold;">#QSearchResult.Status#</td>
	  <td style="font-weight:bold;">#DateFormat(QSearchResult.DateCreated, "m/d/yyyy")#</td>
	  <td style="color:dark blue;"><a href="LogEntry.cfm?EID=#QSearchResult.issueID#"><img src="images/edit.png" alt="Edit Sub Issue" /></a>
	  <img src="images/view.png" alt="View Sub Issue" />
	  </td>
  </tr>
</cfif>
<cfset previousParentIssueID = QSearchResult.ParentIssueID>

Open in new window

0
 
LVL 39

Expert Comment

by:gdemaria
ID: 39953368
As a side note, I also think the page would look good if you just place the icon on the same line as the parent (with the other two icons).   That would save you a lot of rows that are there just for the Add icon.   BUt that's up to you and your clients... just my 2 cents.
0
 

Author Comment

by:lulu50
ID: 39953825
gdemaria,

I made the changes but, I only able to have one add in one of the parents.

Yes, I agree I should not have an extra row for the ad

<cfoutput query="QSearchResult" startrow="#start_record#" maxrows="#records_per_page#">

 <cfif val(QSearchResult.ParentIssueID)> 
 <!-- //Child Row -->
 <tr class="bg2row">
   <td style="padding-left:20px;">#QSearchResult.issueID#</td>
 <td>#QSearchResult.ticketNumber#</td>
 <td>#QSearchResult.Category#</td>
 <td>#QSearchResult.TitleOfIssue#</td>
 <td>#QSearchResult.Status#</td>
  <td>#DateFormat(QSearchResult.DateCreated, "m/d/yyyy")#</td>
    <td><a href="LogEntry.cfm?TechType=#QSearchResult.CategoryTypeID#&ID=#QSearchResult.issueID#"><img src="images/edit.png" alt="Edit Sub Issue" /></a>
    <img src="images/view.png" alt="View Sub Issue" />
    </td>
    </tr>  
 <cfelse>
 <tr class="bgrow">
	 <td style="font-weight:bold;padding-left:5px;">#QSearchResult.issueID#</td>
	 <td style="font-weight:bold;">#QSearchResult.TicketNumber#</td>
	 <td style="font-weight:bold;">#QSearchResult.Category#</td>
	 <td style="font-weight:bold;">#QSearchResult.TitleOfIssue#</td>
	 <td style="font-weight:bold;">#QSearchResult.Status#</td>
	  <td style="font-weight:bold;">#DateFormat(QSearchResult.DateCreated, "m/d/yyyy")#</td>
	  <td style="color:dark blue;"><a href="LogEntry.cfm?EID=#QSearchResult.issueID#"><img src="images/edit.png" alt="Edit Sub Issue" /></a>
	  <img src="images/view.png" alt="View Sub Issue" />
      <cfif QSearchResult.currentRow gt 1 and val(previousParentIssueID)>
      <a href="AddChild.cfm?EID=#previousParentIssueID#"><img src="images/add.png" alt="Add Child" /></a>
      </cfif>
      
	  </td>
  </tr>
</cfif>
<cfset previousParentIssueID = QSearchResult.ParentIssueID> 

 
</cfoutput>

Open in new window




as
0
Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

 

Author Comment

by:lulu50
ID: 39953853
I got it!!!!!!!!!!
0
 

Author Comment

by:lulu50
ID: 39953872
It's working!!!!!!!!!!!!

this is what I did.

<cfset previousParentIssueID = QSearchResult.ParentIssueID> 
<cfoutput query="QSearchResult" startrow="#start_record#" maxrows="#records_per_page#">

 <cfif val(QSearchResult.ParentIssueID)> 
 <!-- //Child Row -->
 <tr class="bg2row">
   <td style="padding-left:20px;">#QSearchResult.issueID#</td>
 <td>#QSearchResult.ticketNumber#</td>
 <td>#QSearchResult.Category#</td>
 <td>#QSearchResult.TitleOfIssue#</td>
 <td>#QSearchResult.Status#</td>
  <td>#DateFormat(QSearchResult.DateCreated, "m/d/yyyy")#</td>
    <td><a href="LogEntry.cfm?TechType=#QSearchResult.CategoryTypeID#&ID=#QSearchResult.issueID#"><img src="images/edit.png" alt="Edit Sub Issue" /></a>
    <img src="images/view.png" alt="View Sub Issue" />
    </td>
    </tr>  
 <cfelse>
 <tr class="bgrow">
	 <td style="font-weight:bold;padding-left:5px;">#QSearchResult.issueID#</td>
	 <td style="font-weight:bold;">#QSearchResult.TicketNumber#</td>
	 <td style="font-weight:bold;">#QSearchResult.Category#</td>
	 <td style="font-weight:bold;">#QSearchResult.TitleOfIssue#</td>
	 <td style="font-weight:bold;">#QSearchResult.Status#</td>
	  <td style="font-weight:bold;">#DateFormat(QSearchResult.DateCreated, "m/d/yyyy")#</td>
	  <td style="color:dark blue;"><a href="LogEntry.cfm?EID=#QSearchResult.issueID#"><img src="images/edit.png" alt="Edit Sub Issue" /></a>
	  <img src="images/view.png" alt="View Sub Issue" />
                 <cfif not val(previousParentIssueID)>
      <a href="AddChild.cfm?EID=#QSearchResult.issueID#"><img src="images/add.png" alt="Add Child" /></a>
      </cfif>
	  </td>
  </tr>
</cfif>
</cfoutput>

Open in new window



ad
0
 

Author Comment

by:lulu50
ID: 39953889
Could not have done it without you!!!!!!!!!!!!!!!!!!!

Thank you lol
0
 

Author Closing Comment

by:lulu50
ID: 39953891
Excellent+++++
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 39953959
Super, glad it worked!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Loops Section Overview
Suggested Courses
Course of the Month12 days, 20 hours left to enroll

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question