PocketQuery and SQLforConfluence
Asked by artafon:

Hi.

I have 2 the same sql query with columns: ID, Summary, Desc

In PocketQuery, data is displayed with the same column width. But, In SQLForConfluence - columns of different widths.

So, In desc columns I see all the text.

Could you help me please, is it real in PocketQuery?


Answers:
author: Carla Roocks (Scandio)
body: Hi Artashes,

you can make it possible for the user to change the column width by setting the parameter *colresizable:true* for the template in question. Then the column widths can be adjusted by draging the borders, so the full content becomes visible. Is this what you have in mind?

This minimalistic template simply adds the resizing function to the default template:

```
## @param colresizable:true$PocketQuery.template("default")
```

"Load macro dynamically" has to be disabled for this to work, that's a known issue we will take care of.

Does this solve your problem? Let me know if you need further help.

Regards,

Carla

comments: author: artafon
body: Carla Hi!

thx for your reply. Could you tell me please, where is the default template?


author: Carla Roocks (Scandio)
body: If you add a new Query in the PocketQuery administration, you can set a template that is used for displaying it. Among the choices you will always find a template called "default" that is a simple table.

Have you already had a look at the templating section in the [PocketQuery Documentation](https://www.scandio.de/atlassian/en/plugins/pocketquery) (the very last tab)? You will find lots of information there, including the source code of the default template (in case you want to further adjust it).

The code snippet I gave you above is also a complete and working template. Simply add it as a new template in the PocketQuery administration with a reasonable name and you can select it for your queries.

The templates are quite powerful. It's really worth having a closer look at that feature :smile:


author: artafon
body: You are not understood :smile:

So, what I do:

I added new template with code default from your site

```
&lt;table class="pocketquery-table confluenceTable"&gt;  &lt;tr&gt;  #foreach ($column in $columns)    &lt;th class="col-$velocityCount"&gt;$!column&lt;/th&gt;  #end  &lt;/tr&gt;  #foreach ($row in $result)    &lt;tr class="#if($velocityCount % 2 !=0)odd#{else}even#end"&gt;    #foreach ($column in $row)      &lt;td class="col-$velocityCount"&gt;$!column&lt;/td&gt;    #end    &lt;/tr&gt;  #end&lt;/table&gt;
```

Then, I need to add your code(parametr) above. Where?


author: Carla Roocks (Scandio)
body: Ah, you already have your template :smile:

Then just add the parameter at the very beginning:

```
## @param colresizable:true&lt;table class="pocketquery-table confluenceTable"&gt;  &lt;tr&gt;  #foreach ($column in $columns)    &lt;th class="col-$velocityCount"&gt;$!column&lt;/th&gt;(...)
```


author: artafon
body: oookey, but it doesn't work.

Columns the same.


author: Carla Roocks (Scandio)
body: They are initially the same width, but they should be adjustable if you grab the border between two of them with the mouse and move it. Is that not possible?

Hm, could you doublecheck if the option "Load macro dynamically" is disabled? And if this query really does not use the default template anymore but your new customized one?


author: artafon
body: No, it's not possible.

Option - "load macro dynamically" is disabled. I can sort by column only.


author: artafon
body: Carla, I resolved.

So. it does not work, if the macros PQ is macros Expand. If macros on page - grab the border works. But after F5 everything returns to its original position. Can we fix columns such as SQLForConfluence?


author: Carla Roocks (Scandio)
body: Interesting behavior with the expend macro, thanks for pointing it out to us!

I just had a closer look at the SQL for Confluence plugin and their table layout. The following template turned out similar for me, please try it out:

```
&lt;table class="confluenceTable stickyTableHeaders"&gt;&lt;tbody&gt;&lt;tr&gt;#foreach ($column in $columns)    &lt;th class="confluenceTh"&gt;$!column&lt;/th&gt;  #end  &lt;/tr&gt;  #foreach ($row in $result)    &lt;tr"&gt;    #foreach ($column in $row)      &lt;td class="confluenceTd"&gt;$!column&lt;/td&gt;    #end    &lt;/tr&gt;  #end&lt;/tbody&gt;&lt;table&gt;
```


author: artafon
body: Yes Yes Yes, this is what i need.

I wonna be coders such as you :) What am I should to know?

Thx you very much.


author: Carla Roocks (Scandio)
body: Glad I was able to help :smile:

Have fun exploring the possiblities of PocketQuery!


Tags: confluence-administration