Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to set message when result is empty in PocketQuery?

John Miller November 19, 2014

I am querying several columns from a large database but some of the results are empty because they are so in the database, which is fine. The problem is that when PocketQuery hits an empty result it just echoes that portion of my template, so the row looks like this:

$query.description

Is there a way to change this behavior? I'd like it to say something like "None Available" or just be blank. How can I do this?

I'd also like to know how to set column widths in my template, this isn't working:

<th class="col-$velocityCount" width="70%">Description</th>

Thanks!

1 answer

1 accepted

2 votes
Answer accepted
Felix Grund (Scandio)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 19, 2014

Hi John!

Thank you for your interest in PocketQuery! What you want to achieve should be fairly straight-forward.

For the description field, you can simply write this in your template to leave the cell blank:

$!query.description

If you want to write something else if the value is blank, you can do this:

#if($query.description)$query.description#{else}None Available#end

Regarding your column width, you should write some CSS instead of using the width attribute (which is deprecated and not supported in HTML5). You can easily write a <style>...</style> tag on top of your template and write arbitrary CSS. Just make sure you write your selectors with .pocketquery-view in front such that you scope your selectors for the PocketQuery table only. It's described with many references in this StackOverflow article how to style the width of your table columns.

Let me know if you need further help!

Regards, Felix [Scandio]

 

John Miller November 20, 2014

I see, thanks! How about if I want to display something particular for a result that is not empty but contains a keyword or something? Like <pre>#if($query.price('0.0'))$query.description#{else}Unlisted#end</pre>

John Miller November 20, 2014

Oops, it didn't like that formatting, but you get the idea: if query.price = 0.0 then show Unlisted.

Felix Grund (Scandio)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 20, 2014

Try like this: #if($query.price.equals('0.0'))$query.price#{else}Unlisted#end Or if it's a number in your database: #if($query.price == 0.0)$query.price#{else}Unlisted#end

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, loom, loom for training, loom for teaching, video training, async learning, online education, screen recording, loom tutorials, loom use cases, atlassian learning, team training tools, instructional video, virtual training tools

🛗 Elevate Your Training and Enablement with Loom

Join us June 26, 11am PT for a webinar with Atlassian Champion Robert Hean & Loom’s Brittany Soinski. Hear tips, stories, and get your burning questions answered. Learn how Loom makes training and enablement easier. Don’t miss it!

Register today
AUG Leaders

Atlassian Community Events