Fork me on GitHub

🙏 If you have any input on how to best learn Fulcro, please that I will feed back to ☝️


I’m building a simple Todo app in Fulcro RAD that has Todos organized into Projects. I have a simple RAD report that lists all Projects. Projects can have many Todos (via a ref attribute). My report’s source-attribute is :projects/all-projects, a global resolver that returns all :project/ids. My report columns are “:project/label”, “:project/project-todos” and “:todo/label” (:todo/label is a “to-many” :ref from :project/project-todos to :todo/id). When I render the report, it displays the :project/label and :project/project-todos a vector of id’s (which makes sense). However, I would like to display the :todo/labels in the report. What’s the proper way to have the report render the individual :todo/labels themselves instead of the “idents in a list” that it displays by default? Link to the c.e.model.project.cljc: And a link to the c.e.ui.project.cljc:


The trivial answer is to make a resolver on an invented property name on the back-end. The alternative is more complicated, but there are many alternatives. Is the invented propery like :project/sample-todo-labels where the resolver sends back a comma-separated string not good enough?


The main alts are: • Custom BodyItem • Row query inclusions (alternate to prior, cannot be used together) with a custom column renderer.


Hi @U0CKQ19AQ I think the invented property name you suggested would work in most cases. Does the invented property need to have an associated attribute defined in the model or is defining a resolver sufficient for this approach?


For learning purposes, I’m curious about how custom BodyItem and row query inclusions would work. Is there some example code somewhere that implements that? Thanks for the info!


You’ll need an attr in order to add it as a column

👍 1

in CLJC, you can co-locate the resolution with the attr


On the other: Reports have to have a component for the report rows. The macro, by default, generates one (with -Row as a suffix to your report component’s name). That generated row component has the query for the cols + row query inclusions and an ident based on the id attribute of the row. If you specify BodyItem then you’re making the row component. It’s just a standard Fulcro component. You specify the ident, query, etc. From there the report component will just pass you props for the row, which you can render, or you can call the helper for row rendering the that plugin uses.


The macro isn’t a ton of code…for educational purposes it is probably worth reading


Ok - that makes sense. Thanks. What is the name of the macro that generates the -Row component?


defsc-report 😄


it generates your report component, and if you don’t tell it the row component (BodyItem), it generates that too


re: defsc-report Doh! I probably could have guessed that one..facepalm


@U0CKQ19AQ could you be so kind and elaborate on > Row query inclusions (alternate to prior, cannot be used together) with a custom column renderer. namely what do you mean by "a custom column renderer"? I know I can have a custom ro/column-formatters but that does not help me because I do not have a column for the child entites (todos) added via row-query-inclusion . Did you mean essentially replacing the default sui-report/render-table-row ( with a custom one, that both renders the report columns and the row-inclusion-provided todos?


I mean you can do a bunch of different things. There are escape hatches everywhere. You can customize render of a column with column formatters, you can take over row query/ident/rendering with BodyItem, you can take over the entire rendering of the table by supplying a body, etc. The generated row component generates a query. Read the macro. See where row-query-inclusions is used? See where BodyItem overrides the generated one? It’s pretty straightforward in the code I think. The rendering plugin doesn’t have many constraints from RAD itself (other than a basic entry point). I wrote SUI renderers one way, but there is definitely room to do it others.


Thank you. I did have a look at the code. My understanding it: 1. I can add the data using row-query-inclusion but then I cannot use column-formatters to show them - because on which column would I do that? There is no column for the data, it was added via query inclusion. Unless I add a dummy attribute and take over its column with a custom column formatter that would render the data from the query inclusion there. 2. Or I can have specify a ro/BodyItem with the desirable query and e.g. a custom row rendering to display them. 3. (I'm sure there are other, though perhaps more involved, solutions, such as completely replacing the report layout) Is that correct?