How to add a selectable table row component with no content #4721
Unanswered
benryanwilliams
asked this question in
Q&A
Replies: 1 comment 4 replies
-
Hi @benryanwilliams you can apply some default styles on your components in order to give them some initial dimension and being able to drop other components inside. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
What I'm trying to achieve
N.B. This is just background information and isn't required to answer the question, so just go to 'The problem that I have' below if you don't want to read all of this.
I've created a for-each block and conditional text block (which both use Shopify's liquid template language to generate html to be rendered server-side) so that the user can use their data to automatically populate their document e.g. 'for each invoice in sales.invoices, display the invoice number, customer id and invoice amount', and I'm therefore trying to create separate table components (table shell, table-row and table-cell), so that the user can achieve the following two examples:
Example 1 - showing simple invoice details horizontally in a table
table-shell
block (html content is just<table></table>
) onto the canvasfor-each
block into thetable-shell
component and select 'for each invoice in sales.invoices'table-row
block (html content is just<tr></tr>
) into thefor-each
componenttable-cell
blocks (html content is just<td></td>
) into thetable-row
componentconditional-text
block into eachtable-cell
component, selecting the following conditions:cell 1) If invoice.number exists, insert invoice.number, else insert 'N/A'
cell 2) If invoice.customer.id exists, insert invoice.customer.id, else insert 'N/A'
cell 3) If invoice.amount exists, insert invoice.amount, else insert 'N/A'
And the idea is that when rendering it will display a table containing a row for each invoice in sales.invoices, and 3 cells in each row, containing the invoice.number, invoice.customer.id and invoice.amount respectively.
Example 2 - showing simple invoice details vertically in a table
table-shell
block (html content is just<table></table>
) onto the canvastable-row
blocks (html content is just<tr></tr>
) into thetable-shell
componentfor-each
block into eachtable-row
component and select 'for each invoice in sales.invoices'table-cell
block (html content is just<td></td>
) into eachfor-each
componentconditional-text
block into eachtable-cell
component, selecting the following conditions:cell 1) If invoice.number exists, insert invoice.number, else insert 'N/A'
cell 2) If invoice.customer.id exists, insert invoice.customer.id, else insert 'N/A'
cell 3) If invoice.amount exists, insert invoice.amount, else insert 'N/A'
And the idea here is that when rendering it will display a table with 3 rows, and each row will contain a cell for each invoice in sales.invoices. The first row will display the invoice.number for each invoice, the second row will display the invoice.customer.id for each invoice, and the third row will display the invoice.amount for each invoice.
The problem that I have
My custom
table-row
component is not selectable, and I can't drag other blocks e.g.for-each
andtable-cell
into it unless I add some default content to the component:I want to be able to drag a
table-row
block into the canvas without any content, but if I remove thecontent
line I can't select it or drag other components into it. Please see both videos below:Video 1 - with content line - Allows selection of row and inserting of cells but text inside row is still displayed
Screen.Recording.2022-11-10.at.11.41.31-1.mov
Video 2 - without content line - Doesn't allow selection of row or inserting of cells
Screen.Recording.2022-11-10.at.11.45.32-1.mov
Is this because of the default way that table rows are treated by the grapesjs framework? If so, is there any way of changing this?
The same actually goes for creating any component types without content - if I try to create a div container component type (used for the for-each container), I cannot drag anything into it unless I add some content or sub-components. Is there no way of creating a component type that only has one level e.g.
<div id="ilzvk" liquidtag="foreach" liquid="for invoice in sales.invoices" class="for-each-container"></div>
but with the ability to select it / drop other components inside of it?Beta Was this translation helpful? Give feedback.
All reactions