You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a very flexible data scheme in my project that allows each data item coming from the backend to define its own display dijit class, so each one is rendered on the frontend using a dijit prototype instantiated using a field in the item itself. I'm having trouble using this approach with dgrid.
I've tried to use dgrid/editor to instantiate dijits using row data, but there seems a chicken-and-egg problem.
The intention is that the first row be rendered using the mydijits/Foo dijit and the second using mydijits/Bar. I'm currently achieving this sort of thing using getObject:
array.forEach(items, function(item) {
var proto = dojo.getObject(item.dijitClass);
var d = new proto(item);
d.placeAt(somewhereUseful);
})
With dgrid, when defining the column structure we have two options..
1/ use dgrid/editor - this requires knowing the dijit class to use for each cell beforehand, e.g. editor({label: 'foo', field: 'bar'}, TheDijitProto). https://github.com/SitePen/dgrid/wiki/Working-with-Widgets looks promising, so the editor knows how to clean up after itself if a dijit was instantiated, but cannot be told to create dijits in a more creative way.
2/ use renderRow or renderCell.
renderRow on an OnDemandList can instantiate my dijit based on data in each item, and return the domNode. However, then it's never cleaned up when the row is destroyed. I tried using the aspect/before code mentioned in 1/ to hook onto the grid's removeRow function to do my own cleanup, but it was never invoked.
I hesitate to say which approach is 'better'. The use of the word 'editor' in dgrid/editor when wanting to simply render a custom dijit in a column makes it sound like it's not the right solution.
The text was updated successfully, but these errors were encountered:
I am checking now dgrid and I strongly support that requirements , moreover from my experience in previous frameworks ,
There's a need to allow what I call business rules in row level ,
aka when changing a field in a row , being able to replace widget in other column based on that selection.
As for your issue below I would use 1 but would pass it what's ever needed to instantiate the Widget , would let you know if I find better approach.
I have a very flexible data scheme in my project that allows each data item coming from the backend to define its own display dijit class, so each one is rendered on the frontend using a dijit prototype instantiated using a field in the item itself. I'm having trouble using this approach with dgrid.
I've tried to use dgrid/editor to instantiate dijits using row data, but there seems a chicken-and-egg problem.
Consider my pseudo data:
The intention is that the first row be rendered using the mydijits/Foo dijit and the second using mydijits/Bar. I'm currently achieving this sort of thing using getObject:
With dgrid, when defining the column structure we have two options..
1/ use dgrid/editor - this requires knowing the dijit class to use for each cell beforehand, e.g. editor({label: 'foo', field: 'bar'}, TheDijitProto). https://github.com/SitePen/dgrid/wiki/Working-with-Widgets looks promising, so the editor knows how to clean up after itself if a dijit was instantiated, but cannot be told to create dijits in a more creative way.
2/ use renderRow or renderCell.
renderRow on an OnDemandList can instantiate my dijit based on data in each item, and return the domNode. However, then it's never cleaned up when the row is destroyed. I tried using the aspect/before code mentioned in 1/ to hook onto the grid's removeRow function to do my own cleanup, but it was never invoked.
I hesitate to say which approach is 'better'. The use of the word 'editor' in dgrid/editor when wanting to simply render a custom dijit in a column makes it sound like it's not the right solution.
The text was updated successfully, but these errors were encountered: