Skip to content

Commit

Permalink
Updated with Git-Sync
Browse files Browse the repository at this point in the history
  • Loading branch information
dongrentianyu committed Aug 30, 2023
1 parent 6ba226c commit 9ccd303
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
created: 20230830081348725
creator: 马不前
modified: 20230830081348725
modifier: 马不前
title: $:/config/ViewToolbarButtons/Visibility/$:/plugins/FSpark/TiddlerScreenshot/captureButton

hide
31 changes: 31 additions & 0 deletions tiddlers/tbl-column-list-video-link.tid
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
code-body: yes
created: 20230830082456893
creator: 马不前
modified: 20230830083237391
modifier: 马不前
tags: $:/tags/Table/HeaderTemplate 如何自定义动态表格的表头
tbl-column-list: video-link
title: tbl-column-list-video-link
type: text/vnd.tiddlywiki

<$reveal type="nomatch" stateTitle=<<tempTableSort>> stateIndex="sortIndex" text=<<currentColumn>> tag="th">
<$button setTitle=<<tempTableSort>> setIndex="sortIndex" setTo=<<currentColumn>> class="tc-btn-invisible tc-tiddlylink" >
<$action-setfield $tiddler=<<tempTableSort>> $index="hasnegate" $value="false"/>
<$action-setfield $tiddler=<<tempTableSort>> $index="negate" $value=""/>
<span style="text-transform: capitalize;"><$transclude tiddler=<<currentColumn>> field="tbl_caption"> 视频链接 </$transclude></span>
</$button>
</$reveal>
<$reveal type="match" stateTitle=<<tempTableSort>> stateIndex="sortIndex" text=<<currentColumn>> tag="th">
<$list filter="[<tempTableSort>getindex[hasnegate]match[false]]" variable=ignore><!--set negate for sort-->
<$button setTitle=<<tempTableSort>> setIndex="hasnegate" setTo="true" class="tbl-sort-svg tc-btn-invisible tc-tiddlylink" >
<$action-setfield $tiddler=<<tempTableSort>> $index="negate" $value="!"/>
<span style="text-transform: capitalize;"><$transclude tiddler=<<currentColumn>> field="tbl_caption"> 视频链接 </$transclude></span> {{$:/core/images/down-arrow}}
</$button>
</$list>
<$list filter="[<tempTableSort>getindex[hasnegate]match[true]]" variable=ignore><!--remove negate for sort-->
<$button setTitle=<<tempTableSort>> setIndex="hasnegate" setTo="false" class="tbl-sort-svg tc-btn-invisible tc-tiddlylink" >
<$action-setfield $tiddler=<<tempTableSort>> $index="negate" $value=""/>
<span style="text-transform: capitalize;"><$transclude tiddler=<<currentColumn>> field="tbl_caption"> 视频链接 </$transclude></span> {{$:/core/images/up-arrow}}
</$button>
</$list>
</$reveal>
22 changes: 22 additions & 0 deletions tiddlers/如何自定义动态表格的表头.tid
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
created: 20230829224150779
creator: 马不前
modified: 20230830083558512
modifier: 马不前
tags: 插件技巧类 Shiraz宏包
title: 如何自定义动态表格的表头

今天才发现设拉子也是支持自定义模板的,还可以自定义各种功能。完美地契合了太微高度自定义的特性。特别是里面的动态表格,里面的内容也是可以自定义的,包括表头和表格里的内容。一个常见的需求是把某个时间格式转换成想要的格式。这些在[[文档里|https://kookma.github.io/TW-Shiraz/#demo%2Fdynamic-tables-template]]可以看到。

这里举一个自定义动态表格表头的例子。一般来说,表头展示的是和要展示的字段内容是一致的,但如果字段名很长,而要列出的字段又很多,就会排特别长,显得不太好看。所以有没有一种方式可以用别名的形式显示这些字段呢?当然是可以的。

<$macrocall $name=table-dynamic caption="已完成的主题列表" filter="[tag[B站直播]!tag[任务]]" fields="title tags video-link" class="w-100"/>

比如上面的例子,`video-link`可能就显得有些长了。那么我们怎么改呢?

首先找到[[$:/plugins/kookma/shiraz/templates/header/default]],然后复制一份,并在新条目里添加一个字段`tbl-column-list`,里面的值就是我们要转换的值字段值。

再把里面的`<$text text=<<currentColumn>>/>`转换成`<$transclude tiddler=<<currentColumn>> field="tbl_caption"> <<currentColumn>> </$transclude>`,在这个基础上,再把里面的`<<currentColumn>>`,改成我们想展示的内容,这里我们写`视频链接`,大概有三处。

可以去[[tbl-column-list-video-link]]查看相应的代码,演示的效果已经在上面了。

方案来源于[[论坛|https://talk.tiddlywiki.org/t/shiraz-dynamic-table-plugin-column-captions-and-tbl-column-list/5666/10]]。

0 comments on commit 9ccd303

Please sign in to comment.