-
Notifications
You must be signed in to change notification settings - Fork 12
Cell (get/formatter/renderCell) #12
Comments
I'm not understanding how these concerns are irrelevant. Are you envisioning that the widget for To avoid duplicating dgrid cell-rendering logic and keep the API user-friendly, simple use-cases are provided by single-purpose functions:
Some way or another I think it is of value to continue providing these mechanisms in dgrid 2. |
I was thinking the widget for "cell" renders the My point about irrelevancy is that because |
dgrid 1 currently has a lot of flexibility while managing to not get too complicated. One thing I think is important is the pipeline: get -> formatter -> renderCell
One thing I think is important is that dgrid always handles creating the required cell structure. None of these methods requires the user to re-implement dgrid logic (e.g. dgrid cell attributes, like ===== So... if we have a single method that accepts a
And for registering a different widget to render 'cell':
|
...sorry to be long-winded, I'm not attached to old ways for sentimentality, I just want to make sure we have a flexible and friendly API moving forward! |
I think, then, the thing I left out from my initial analysis is that while I wasn't 100% happy with using Perhaps a solution is to introduce a third option to handle this use case and introduce the following callbacks:
|
To answer more of these questions, the callbacks should handle these situations:
The only time you'd have to recreate the |
Enhancement
In dgrid 1, the
get
function was used to return a text value andformatter
was used to return HTML - inserted in the standard cell wrapper. In addition to this, renderCell could be used to return your own DOM which would use the value ofget
butformatter
wouldn't be called as part of this lifecycle.get
is a way to prevent HTML injection that may come from user data andformatter
is a way to mark the HTML as potentially safe.Ken, in his brain dump, noted that this decision for this API was mostly a legacy holdover . He proposed re-implementing these methods as renderCell, renderText, and renderHtml.
DNode
already combines renderText and renderHtml (through theinnerHTML
property). Also, because dgrid 2 uses a registry,renderCell
is accomplished instead by registering a different widget for 'cell'.Our implementation should look like this:
render
is used, it is the only method that is called with item and column data and no value is foundget
is used, it is called with item and column data to find the valuerenderValue
is used, it is called with the value and the item and column datarender
,renderValue
, or a stringified value is passed to the cell so that the cell has both the value and the contentThe text was updated successfully, but these errors were encountered: