var widgets = Model.Content.GetPropertyValue<IDictionary<string, IEnumerable<int>>("widgets");
var nodeIds = widgets["cell1"];
foreach(var id in nodeIds){
// Do something with the node id
}
Suggestion: I think it would be a huge help if complex datatypes like Widget Grid had a helper class to make it super easy for smalldevs like me and nondevs to do pull this off. Great idea isnt it :D
You are right that it needed an extra >. For why you are getting null, it seems I made it a dictionary of IPublishedContent arrays not ints, so just change the generic int param to IPublishedContent instead and that should then work.
I'll have a look at creating a helper class in the next release.
var cellLeft ="c21"; // id in table for content in cell 1 (left) in second row var cellRight ="c22"; // id in table for content in cell 2 (right) in second row var widgets = Model.Content.GetPropertyValue<IDictionary<string, IEnumerable<IPublishedContent>>>("widgets"); var nodesRight = widgets[cellRight]; // get nodes foreach(var node in nodesRight){ @Html.Partial("Partials/widget-"+ node.DocumentTypeAlias, node) // render partial macros based on alias name }
U7 Razor Example on how to render Widget grid in template?
How do get the selected nodeids ?
I get as far as:
which returns true when cell exists .. but how to get the data? I've tried:
but no luck
best
Jesper
Hey Jesper,
It's stored as a dictionary of int arrays
So to retrive the values you'd do something like
Hope this helps.
Matt
Thanks matt .. but this line
doesnt compile. It says : is a 'type' but is used like a 'variable'. So I added a missing >
But now widgets is null ..
If I poke around in immediate window a little I can see:
Sorry to bother you ;)
Suggestion: I think it would be a huge help if complex datatypes like Widget Grid had a helper class to make it super easy for smalldevs like me and nondevs to do pull this off. Great idea isnt it :D
/Jspr
Hey Jesper,
You are right that it needed an extra >. For why you are getting null, it seems I made it a dictionary of IPublishedContent arrays not ints, so just change the generic int param to IPublishedContent instead and that should then work.
I'll have a look at creating a helper class in the next release.
Matt
Hey Matt,
Works. Thank you! https://www.youtube.com/watch?v=r13riaRKGo0&feature=kp
For completeness:
best
Jesper
is working on a reply...