TreeTable: how to add link to download file through browser

UI Components for Vue
Post Reply
aircable
Posts: 2
Joined: 21 Oct 2022, 22:41

21 Oct 2022, 22:52

Hi,

I'm trying to template a column to add a href link to a file name. Original: https://primefaces.org/primevue/treetable/templating
The Column:

Code: Select all

<Column field="name" header="Name" :expander="true"></Column>
contains just the file name.
What I want is the rendering to include the link to the file.
I found this as a potential answer: https://stackoverflow.com/questions/677 ... s-as-links
But I can't make it work for Columns.

My code here looks like this:

Code: Select all

<TreeTable
    :value="viewedDirectory"
    class="p-treetable-sm"
    sortMode="single"
    selectionMode="single"
...
  >
    <Column
      field="name"
      header="Name">
...
Is there a way to have the column automatically render the "name" as something like

Code: Select all

<a :href="{{ site.apiurl }}/name">{{ name }}</a>
instead of just a <span/>

Thank you for any ideas.
Last edited by aircable on 28 Oct 2022, 00:47, edited 1 time in total.

bahadirsofuoglu
Posts: 30
Joined: 06 Sep 2022, 08:59

25 Oct 2022, 09:57

Hi,
I'm not sure I understand correctly. But for a first look, you can keep your Columns information in an array. You can edit this array and use it dynamically when needed.

aircable
Posts: 2
Joined: 21 Oct 2022, 22:41

26 Oct 2022, 01:04

I don't think I have access to the column array.
Rendering of the TreeTable template is done automatically. The <Column field="name" automatically renders to the <span>...
What I would like to see is that the TreeTable shows files with a link for download. And I have never seen an example that does that.
For a file manager it would be just normal to have the files shown downloadable. (or right click save-as)

Here is the file manager I'm working on:
https://github.com/Kibo/filemanager-js/ ... anager.vue

Post Reply

Return to “PrimeVue”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests