This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <tbody> | |
| @for (int i = 0; i < Model.Things.Length; i++) | |
| { | |
| <tr> | |
| <td> | |
| @Html.DisplayFor(m => Model.Things[i].Number) | |
| </td> | |
| <td> | |
| @Html.DisplayFor(m => Model.Things[i].Text) | |
| </td> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <tbody> | |
| @Html.DisplayFor(m => m.Things) | |
| </tbody> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <input id="Things_1__Text" name="Things[1].Text" type="hidden" value="Two" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface IClientSortable | |
| { | |
| int ClientOrder { get; set; } | |
| } | |
| public class SortableThing : IClientSortable | |
| { | |
| public string Text { get; set; } | |
| public int Number { get; set; } | |
| public bool IsEven { get; private set; } | |
| public int ClientOrder { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @using (Html.BeginForm("Index", "Sort", FormMethod.Post, new{role = "form", @class="form-inline"})) | |
| { | |
| <h1>Sorting</h1> | |
| <table id="table-sortable" class="table table-bordered table-striped table-hover table-responsive"> | |
| <caption>Sortable things</caption> | |
| <thead>. . .</thead> | |
| <tbody>@Html.DisplayFor(m => m.Things)</tbody> | |
| </table> | |
| <div class="form-group"> | |
| <input type="submit" name="discard" value="Discard" class="btn btn-default" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <tr> | |
| <td> | |
| @Html.HiddenFor(m => m.ClientOrder, new { @class = "data-sort" }) | |
| @Html.HiddenFor(m => m.Number) | |
| @Html.DisplayFor(m => m.Number) | |
| </td> | |
| <td> | |
| @Html.HiddenFor(m => m.Text) | |
| @Html.DisplayFor(m => m.Text) | |
| </td> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DGON_DOTNET.ClientInteraction = | |
| { | |
| makeSortable: function (tableSelector, options) { | |
| options = optionsWithDefaults(options, { | |
| handleSelector: '.handle', | |
| sortSelector: '.data-sort' | |
| }); | |
| var tbody = $(tableSelector + ' tbody'); | |
| $(tbody).sortable({ | |
| helper: maintainWidth, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function reorder(rows, sortSelector) { | |
| $(rows).each(function (index) { | |
| var $row = $(this); | |
| $row.find(sortSelector).val(index); | |
| }); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [HttpPost] | |
| public ActionResult Index(string save, string discard, SortViewModel posted) | |
| { | |
| if (isSave(save, discard)) | |
| { | |
| _repository.Save(SortableThing.ToThings(posted.Things)); | |
| } | |
| IEnumerable<Thing> updatedThings = _repository.Find(); | |
| var model = new SortViewModel | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static IEnumerable<Thing> ToThings(SortableThing[] from) | |
| { | |
| return from | |
| .Sort() | |
| .Select(st => st.ToThing()); | |
| } |
OlderNewer