Forums

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

user macro within table: using cell value on the same row as parameter

Nicolas Meaux
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 10, 2019

Hello,

 

I wonder how i can use under my user macro, the value on a separate cell in the same row on which i did insert my custom macro within an existing confluence table ?

 

Thanks for help :)

 

Nicolas

1 answer

0 votes
Diego
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 14, 2019

Hello there!

That is an interesting project Nicolas. Fetching the values from within a Confluence table is possible, but by no means it is clean.

We will need to fetch the page value within your User Macro and work from there. Here we have another thread that tries to do exactly this, fetch the page body content within a user macro:

how to get a page content body via velocity in a user macro?

When we have the content, we will then need to identify the values that the macro needs. Another article in our Community might shed some light on how we can work with tables in our macros:

The Admin's tale - User Macro filtering a Confluence table

 

Another option would be to create tables within the macro itself and work from there:

Formatting html table via user macro

 

For short, your project is possible, but not really clean in the end. Looking forward to your reply Nicolas.

Nicolas Meaux
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 17, 2019

Hello Diego,

 

Thanks for your reply and for this very usefull threads.

I did change what i did plan to do and was able to build a full table with a user macro based on my needs.

However i am still looking to a solution to retrieve data from a "master table" based on the first column term selection, in order to build custom pages and separate data & structure for a bunch of pages ( which will be all macro ).

I was not able to make the javascript working on the example i did see :


## @noparams

#set ( $Long = $generalUtil.getSystemStartupTime() )
#set ( $pageId = 5997128 )
#set ( $page = $pageManager.getPage($pageId) )
#set ( $pageContent = $page.getBodyAsString() )
#set ( $searchterm = "check_totob" )

<div id="searchInput$paramFilterID">
$searchterm
</div>

<div id="tableFilter$paramFilterID">
$pageContent
</div>

<script type="text/javascript">
AJS.$("#searchInput$paramFilterID").keyup(function () {
var jqry = AJS.$
var rows = jqry("#tableFilter$paramFilterID tbody tr").hide();
var searchData = this.value;
if (searchData.length) {
var data = searchData.toLowerCase().split(" ");
jqry.each(data, function (search_idx, str) {
rows.filter(function(row) {
var col_to_filter = $paramColumnNumber;
if (col_to_filter>=0) {
var td_to_filter = $(this).children("td").eq(parseInt(col_to_filter));
return $(td_to_filter).text().toLowerCase().indexOf(data) >= 0;
} else {
return $(this).text().toLowerCase().indexOf(data) >= 0;
 }
}).show();
});
} else {
rows.show();
}
});
</script>

rgds

 

Nicolas

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events