right, but i want to create vertical columns of 4 checkboxes -- thats is what the inGroupsOf was supposed to achieve... does that make sesne? i might be able to use the inGroupsOf(4) on the second for-each
ideally, Unit 1 [or any pageHeading that is duplicated] should ONLY appear once [as it would if i could use GroupBy("pageHeading") ;) but alas, i cannot figure out how to use both together :(
okay, i am tinkering with the above... and i get the following error and have no idea what it means...
The type arguments for method 'umbraco.MacroEngines.DynamicNodeList.InGroupsOf(int)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
it has to do with groupsOf and that dynamic node stuff ;)
\listUnits.cshtml(30): error CS0411: The type arguments for method 'umbraco.MacroEngines.DynamicNodeList.InGroupsOf<T>(int)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
GroupBy and inGroupsOf() question
I would like to break a list of unique nodes grouped by the pageHeading property, but when i try to use inGroupsOf(4) in the for each i get an error:
'umbraco.MacroEngines.DynamicGrouping' does not contain a definition for 'InGroupsOf'
here is my code...
Any thoughts or help would be greatly appreciated.
Hey Bob!
I don't think you need the InGroupsOf(). Its actually already grouped from the GroupBy() above.
I think you want to do something like this:
Its hard for my to quite determine what markup you need, but does that help see how it would work?
-Jason
Wow, that didn't work out.
Trying again
var coursesByType = root.Descendants("Class").Where("!isHoliday").GroupBy("pageHeading");
foreach(varcourseTypeincoursesByType)
{
<h2>@courseType.Key</h2>
foreach(var item in courseType.Elements)
{
<p>@item.Name</p>
}
}
right, but i want to create vertical columns of 4 checkboxes -- thats is what the inGroupsOf was supposed to achieve... does that make sesne? i might be able to use the inGroupsOf(4) on the second for-each
stay tuned?
okay, so... it appears that i cannot use groupBy and InGroupsOf together... this works...
however... it does not remove the duplicates...
any thoughts?
What should it look like ideally?
ideally, Unit 1 [or any pageHeading that is duplicated] should ONLY appear once [as it would if i could use GroupBy("pageHeading") ;) but alas, i cannot figure out how to use both together :(
How about doing two loops?
One to remove duplicates and one to group into columns of 4.
Something like this: (not tested)
okay, i am tinkering with the above... and i get the following error and have no idea what it means...
The type arguments for method 'umbraco.MacroEngines.DynamicNodeList.InGroupsOf(int)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
any ideas?
Perhaps this would work?
grrr.... foreach statement cannot operate on variables of type 'object' because 'object' does not contain a public definition for 'GetEnumerator'
so sorry that this is being such a pain in the butt for both of us... :(
Maybe this change? What line is it complaining about?
it has to do with groupsOf and that dynamic node stuff ;)
\listUnits.cshtml(30): error CS0411: The type arguments for method 'umbraco.MacroEngines.DynamicNodeList.InGroupsOf<T>(int)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
actually... if i pull out the inGroupsOf() logic... just building the dynamicNodeList... i get this error... so somethign not correct here either.
) Cannot apply indexing with [] to an expression of type 'object' at CallSite.Target(Closure , CallSite , Object , Int32 )
Yea, I just wrote the code in the RTE quickly. No testing done. Could be that the [0] is actually not correct.
I'll try to setup a test environment if I get a chance.
Thanks,
Jason
We're you able to figure this one out?
-J
i ended up using MOD operator % -- not sure if that is hacky or not... but basically, i don't think groupBy and inGroupsOf can work together :(
Bummer. It did seem a bit like that. Well, glad you found a solution!
-Jason
is working on a reply...