Friends,
I have the following problem. I have a collection of objects being returned from an ASP.NET MVC controller as JSON. In the view, I want to order these objects in a specific order based on a name property.
I attempted to do so by creating a separate JS array. Based on the names property, I insert the object into a specific index in the array.
I'm sure there is a better way to solve this problem. Also I currently getting only the last condition for "events" inserted in every index position. Below is my code to date.
Thanks much!
<script id="tmpl-refinement-results" type="text/template">
<% var sortedFacets = [] %>
<%_.each(SearchAggregationDetails, function(aggValue, y){
if(aggValue.FilterText = "News"){
sortedFacets[0] = aggValue;
}
if(aggValue.FilterText = "Articles"){
sortedFacets[1] = aggValue;
}
if(aggValue.FilterText = "Case Studies"){
sortedFacets[2] = aggValue;
}
if(aggValue.FilterText = "Nice Exhibit Case Studies"){
sortedFacets[3] = aggValue;
}
if(aggValue.FilterText = "Events"){
sortedFacets[4] = aggValue;
}
}) %>
<% _.each(sortedFacets, function(aggregation, i) { %>
<li>
<a href="<%=aggregation.TypeUrl %>"><%=aggregation.FilterText %> <span class="refinement-results-list num-val"> <%=aggregation.DocCount %></span></a>
</li>
<% }); %>
Aucun commentaire:
Enregistrer un commentaire