How do you generate table content?

Hi all,

I’ve created a table-procedure for the resizer widget

Now before I come up with a way to put content into these tables I would like to ask you if you have ideas how that should be done

Within the table procedures the column Index is accessible through <colIndex> or <column> and the row is accessible through rowIndex or <row>

I’m experimenting with filters that can be passed to the procedures and they are then evaluated within the procedures…

This is how the resizable-table looks like:

\procedure resizable-table-content(filter)
\whitespace trim
<%if [<editable>match[yes]] %>
	<$let state={{{ [[$:/state/edit-cell-]addsuffix<colIndex>addsuffix[-]addsuffix<row>addsuffix[-]addsuffix<qualify>] }}}>
		<%if [<state>get[text]!match[yes]] [<state>is[missing]] %>
			<div style.display="flex">
				<div style.flex="1">
					<$wikify name="content" text="""<$text text={{{ [subfilter<filter>get<field>] }}}/>""">
						<<content>>
					</$wikify>
				</div>
				<div>
					<$button class="tc-btn-invisible" set=<<state>> setTo="yes" actions=<<resizable-table-content-create-tiddler-actions>>>
						{{$:/core/images/edit-button}}
					</$button>
				</div>
			</div>
		<% else %>
			<div style.display="flex">
				<div style.flex="1">
					<$edit-text tag="input" tiddler={{{ [subfilter<filter>] }}} focus="yes" class="tc-width-100"/>
				</div>
				<div>
					<$button class="tc-btn-invisible" set=<<state>> setTo="no">
						{{$:/core/images/done-button}}
					</$button>
				</div>
			</div>
		<% endif %>
	</$let>
<% else %>
	<$wikify name="content" text="""<$text text={{{ [subfilter<filter>get<field>] }}}/>""">
		<<content>>
	</$wikify>
<% endif %>
\end

\procedure resizable-table(columns:"", rows:"", columnFilter:"", rowFilter:"", field:"text", editable:"no", tableHeight:"auto", class:"", headerClass:"", cellClass:"", stateTiddlerPrefix:"$:/state/resizable-table/")
\whitespace trim
<$let cellWidth={{{ [[100]divide<columns>addsuffix[%]] }}} stateTiddlerPrefix={{{ [<stateTiddlerPrefix>addsuffix<columns>addsuffix<qualify>addsuffix[/]addsuffix[col-]] }}}>
	<div class={{{ tc-resizable-table-wrapper [<class>] +[join[ ]] }}} style.height=<<tableHeight>> style.width="100%">
		<table class="tc-resizable-table" style.width="100%">
			<%if [<columns>!is[blank]] %>
				<thead>
					<tr class={{{ tc-resizable-table-header [<headerClass>] +[join[ ]] }}}>
						<$list filter="[range<columns>]" variable="column" counter="colIndex">
							<$let nextColIndex={{{ [<colIndex>add[1]] }}} row="0">
								<th style.position="relative" style.min-width=<<tf.get.min.column.width.percentage>> style.max-width=<<tf.get.max.column.width.percentage>> style.width={{{ [<stateTiddlerPrefix>addsuffix<colIndex>get[text]!prefix[Infinity]] :else[<cellWidth>] }}}>
									<div class="tc-resizable-table-cell" style.width="100%">
										<$transclude $variable="resizable-table-content" filter=<<columnFilter>>/>
									</div>
									<%if [<colIndex>!match<columns>] %>
										<$resizer
											class="tc-table-column-resizer"
											direction="horizontal"
											min=<<tf.get.min.column.width.percentage>>
											max=<<tf.get.max.column.width.percentage>>
											default=<<cellWidth>>
											unit="px"
											element="parent.parent"
											onBeforeResizeStart=<<resizable-table-on-before-resize-start-actions>>
											onResize=<<resizable-table-on-resize-actions>>
										/>
									<% endif %>
								</th>
							</$let>
						</$list>
					</tr>
				</thead>
			<% endif %>
			<%if [<rows>!is[blank]] %>
				<tbody>
					<$list filter="[range<rows>]" variable="row">
						<tr class={{{ tc-resizable-table-row [<cellClass>] +[join[ ]] }}}>
							<$list filter="[range<columns>]" variable="column" counter="colIndex">
								<td style.min-width=<<tf.get.min.column.width.percentage>> style.max-width=<<tf.get.max.column.width.percentage>> style.width={{{ [<stateTiddlerPrefix>addsuffix<colIndex>get[text]!prefix[Infinity]] :else[<cellWidth>] }}}>
									<div class="tc-resizable-table-cell" style.width="100%">
										<$transclude $variable="resizable-table-content" filter=<<rowFilter>>/>
									</div>
								</td>
							</$list>
						</tr>
					</$list>
				</tbody>
			<% endif %>
		</table>
	</div>
</$let>
\end

Here’s an example how to call this:

<<resizable-table rows:"5" columns:"5" columnFilter:"[tag[Table]!tag[Row]tag<colIndex>]" rowFilter:"[tag[Table]tag[Row]tag<colIndex>tag<row>]">>

I’m still not settled about how the content should be created, I’m lacking ideas
Maybe it should be possible to create the content like above or (with a switch) by passing a table in wikitext?

Another thing I’m struggling with is the editing mode if a tiddler is missing
I would really like to be able to create a tiddler based on a given filter expression, does anybody here have an idea how that could be done?


Thank you in advance for your help and your ideas,
best wishes from Southtyrol,
Simon

1 Like

i don’t know if it is a way to put content into those tables, but maybe there is something to the tids-to-table plugin idea?

1 Like

Hi @twMat and thanks for the hint!

The link to that plugin came up when I wrote these lines and I had a look at it! Very nice and solid!

Thanks

Here is a dynamic table I have made with option to add categories and subcategories for the contents. It has more customisations options which can be seen on pressing the edit button at the left-top of the table

@arunnbabu81 , your table is VERY impressive!

I’m trying to create a general-purpose resizable-table procedure… I hope I can make that possible somehow

That’s what I’m gathering ideas for

I will look at this in detail tomorrow to see if I can add something.

I have a hunch.

perhaps there are two questions here. one is how to introduce resizable elements to tables and the other is how to make tables and include the first.

if they can be separated the first is finite and can be added to any table. both tiddlywiki markup and html tables have features to assign styles and classes to them. in fact most html elements may be?

PS I saw your dragable corners :clap::clap: bravo

It seems in your example tiddlers you use a row/column numbering. I would change that to column / row and connect the content to a data-tiddler with a col-row numbering too. So the indexes can be the key and the data can be shown in the table. I think that should be straight forward to implement.

The procedure would only need a data parameter, that is connected to the data tiddler. Since data-tiddlers are easy to edit by humans it should also be relatively straight forward to fill them with data.

A second possibility would be a lookup parameter where the data-tiddler is a “lookup-table” so the key = col-row number and the value=tiddler title, that will be transcluded into the table. This will make it possible to have wikitext content within a table cell

IMO both configuration options should be available.

Hope that makes sense.

1 Like

Hi @pmario ,

You mean the keys should be something like 1 1: , 1 2: , 1 3: and so on?
How would you annotate eventual header and or footer cells in this data tiddler? header 1 1: , header 1 2: … ?
There could also be a caption and there could be classes, so a data tiddler could look like this:

header 1 1: header
header 2 1: header
1 1: cell1
2 1: cell2
1 2: cell3
2 2: cell4
caption: my table
classes: tc-table-cool

What do you think?

Now that I see your data-tiddler I think I did confuse row and column in my head. … It must have been late as I wrote it :slight_smile:

Using numbers only will make it impossible for humans to sort it out. We need an Excel like numbering eg: 1 a, 1 b, 1 c … Where “a” is the column and the number is the row.

I did not think about header, footer, caption and classes. … You are right thats a problem.

IMO for humans the following makes more sense.

1 a: cell1
1 b: {{tiddler-title}}
2 a: cell3
2 b: cell4
head A: header col 1
head B: header col 2
foot A: footer col 1
foot B: footer col 2
caption: my table
classes: tc-table-cool

Does that make sense?

@pmario ,

the numbering with letters is finite whereas the numbering with numbers is unfinite

I build the tables out of ranges range<columns> and range<rows> and somehow need to have the corresponding column number somewhere in the data tiddler
We must find a readable way that works with numbers only

Tables allow also more header and footer rows than 1

“unfinite” = finite. Not really a problem. AA, AB, AC, … AAA, AAB, and so on. Since theoretically strings can have an unlimited number of characters its also infinite. With 2 characters we have 26 x 26 = 676 columns. For most TWs that will be enough. For 3 chars we have 26 x 26 x 26 = 17576 columns which imo is overkill already.

Because we also have to multiply this with the number of columns eg: 10. Which would end up in 67,600 cells with only 2 row characters needed.

Internally I would test for 3 chars and in the docs I would mention 1. So 26 columns, which is probably enough for 90% of users. When the first user complains, I would tell them to use 2 starting with AA after Z.

The advantage of characters is that users know it already from Excel and co.

1 Like

Hi,

I once started working on data tiddlers for tables, and here’s an example of a simple data tiddler I came up to:

rows: 2
cols: 4
L1C1: ''Country''
L2C1: France
L1C4: ''Pop.''
L1C3: ''City''
L2C4: 
L2C3: Paris

I guess it could easily be extended with headers definitions like this:

rows: 2
cols: 4
row headers: 1
col headers: 0
L1C1: ''Country''
L2C1: France
L1C4: ''Pop.''
L1C3: ''City''
L2C4: 
L2C3: Paris

Cells coordinates “LnCn” were used in an old spreadsheet software which name I can’t remember now, and I find it quite easy to parse.

Fred

I agree with this. If it is overly difficult to implement it’s not a deal breaker, but AA, AB etc is probably the de facto standard for column naming in spreadsheets. It also has the advantage that “C” obviously refers to a column, whereas “3” would be ambiguous if used for both a row and a column.

Thanks for the reminder. I got rows and columns wrong again. @BurningTreeC I did change my other posts. They should have the numbering right now.

Since TW builds tables per row, the elements defining the row should be together.
Since data-tiddlers are special, we can handle head, foot, caption and classes using names instead of numbers.

Sorry for my late reply to the Question of this topic @BurningTreeC

I generate “complex” table content using html table tags and attributes with first columns and then rows nested inside $list widgets that then allows tiddlywiki script or wikiki text to populate the content of each row/cell, so the above row/column discussion makes no sense to me.

  • If it was nessasary to address the resulting cells via a row/column (not sure why), I imagin I would have persued the use of CSS calc to set an ID or other CSS selector, because I would want to keep the $list widgets for iterating the content eg rows from a list of titles, and columns from a list of fieldnames. ie a logical representation of the information in the table.