Sort by star rating
Sort by star rating
Pennywise
Posts: 15Questions: 3Answers: 1
Hello. I have an input field that displays a number of stars and I would like to sort by the number of stars highlighted. Can't seem to make this work. Here is my HTML:
<table class="table table-striped" id="homeTable" >
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Username)
</th>
<th>
@Html.DisplayNameFor(model => model.OverallRating)
</th>
<th>
@Html.DisplayNameFor(model => model.TotalRatings)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Username)
</td>
** <td>
@{double score = item.OverallRating; }
<input id="input-id" type="number" value="@score" class="rating" data-size="xs" name="OverallRating" data-readonly="true" data-show-clear="false">
</td>**
<td>
@Html.DisplayFor(modelItem => item.TotalRatings)
</td>
<td>
@Html.ActionLink("Details", "SeeContractorReviews", new { id = item.ID })
</td>
</tr>
}
</tbody>
</table>
Any idea how I can get this to work?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Specifically this part:
** <td>
@{double score = item.OverallRating; }
<input id="input-id" type="number" value="@score" class="rating" data-size="xs" name="OverallRating" data-readonly="true" data-show-clear="false">
</td>**
I solved my problem with a hidden div storing the numerical value for the number of stars. Simple enough!