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
First of all I would like to thank for all the work that has been done in this library. I've been using it for a while, and it has been really useful in some of my projects.
Problem:
I am currently facing a problem with trying to write custom filter. I wanted to implement a custom filter that performs a group by and returns a list of grouped objects. I got it sort of working, the problem is that I cannot get it to access the nested objects inside the grouped lists. I can for instance access they key value of the objects, but the list of items seems to be ignored
To illustrate the problem, I have a template that looks like this "<h1>Hello</h1><div> {% assign events_by_type = events | group_by: \"eventTypeId\" %} {% for type_group in events_by_type %} <div> {{type_group.key}} {% for item in type_group.items %} {{ item.name }} {{item}} {% endfor %} </div> {% endfor %} </div>"
and I am using a json object that looks like this: "{\"events\":[{\"eventTypeId\":1234,\"type\":{\"id\":1234,\"name\":\"type 1234\"}}, {\"eventTypeId\": 1111, \"type\":{\"id\":1111,\"name\":\"type 1111\"} }]}"
This is the result I get <h1>Hello</h1><div> <div> 1234 </div> <div> 1111 </div> </div>
This is what I was expecting <h1>Hello</h1><div> <div> 1234 type 1234 </div> <div> 1111 type 1111 </div> </div>
anonymous objects
I have a json object containing all the data I want to render. The catch with this json object is that I cannot register my classes as instructed here. I want it to be generic as possible so I can work with any json object.
For this to happen I thought all I needed to do was to use UnsafeMemberAccessStrategy, but it does not seem to be the case.
I want to be able to do group by using metadata and by simple properties as well, hence why I do ToStringValue().Split(".").
I don't believe this is an issue with the custom filter itself since I can access the key values inside the list of objects. I cannot access the list of items inside the objects though.
I'm not sure if this could be a bug or if it's me.
The text was updated successfully, but these errors were encountered:
Hello there,
First of all I would like to thank for all the work that has been done in this library. I've been using it for a while, and it has been really useful in some of my projects.
Problem:
I am currently facing a problem with trying to write custom filter. I wanted to implement a custom filter that performs a
group by
and returns a list of grouped objects. I got it sort of working, the problem is that I cannot get it to access the nested objects inside the grouped lists. I can for instance access they key value of the objects, but the list of items seems to be ignoredTo illustrate the problem, I have a template that looks like this
"<h1>Hello</h1><div> {% assign events_by_type = events | group_by: \"eventTypeId\" %} {% for type_group in events_by_type %} <div> {{type_group.key}} {% for item in type_group.items %} {{ item.name }} {{item}} {% endfor %} </div> {% endfor %} </div>"
and I am using a json object that looks like this:
"{\"events\":[{\"eventTypeId\":1234,\"type\":{\"id\":1234,\"name\":\"type 1234\"}}, {\"eventTypeId\": 1111, \"type\":{\"id\":1111,\"name\":\"type 1111\"} }]}"
This is the result I get
<h1>Hello</h1><div> <div> 1234 </div> <div> 1111 </div> </div>
This is what I was expecting
<h1>Hello</h1><div> <div> 1234 type 1234 </div> <div> 1111 type 1111 </div> </div>
anonymous objects
I have a json object containing all the data I want to render. The catch with this json object is that I cannot register my classes as instructed here. I want it to be generic as possible so I can work with any json object.
For this to happen I thought all I needed to do was to use
UnsafeMemberAccessStrategy
, but it does not seem to be the case.Here is a simple repro https://dotnetfiddle.net/r0hkwE
I want to be able to do group by using metadata and by simple properties as well, hence why I do
ToStringValue().Split(".")
.I don't believe this is an issue with the custom filter itself since I can access the key values inside the list of objects. I cannot access the list of items inside the objects though.
I'm not sure if this could be a bug or if it's me.
The text was updated successfully, but these errors were encountered: