else { } @if(@ inneritem.RangeEnd == null || @ inneritem.RangeEnd ==) { } 其他 { } } } @ resultDefaultValue @ inneritem.Number 来自:@ inneritem.RangeStart To:@ inneritem.RangeEnd @ inneritem.Description < script> $(document).ready(function(){ $ ('#SortBy')。change(function(){ var value = $(#SortBy option:selected)。val(); alert(value ); }); }) < / script> 解决方案 (document).ready(function(){ ('#SortBy')。change(function (){ var value = (#SortBy option:selected)。val(); 警报(价值); }); }) < ; /脚本> Hi,I have a requirement where I have to sort the content of a html table based on value selected in dropdown.The dropdown contain 2 values: Sort by Number and Sort By Description.On selecting Sort By Number the table should be sorted by Number.On selecting Sort By Description the table should be sorted by Description.This I need to do using MVC and jquery.Please help me out.Thanks. @{ Layout = T4MVC.SharedController.ViewNames._Ctx;} @section brandcrambs{ @{Html.RenderPartial(T4MVC.SharedController.ViewNames._ProductCatalogBrandCrambs, Model);}}@Html.DropDownList("SortBy", new List<SelectListItem>{ new SelectListItem{ Text="Sort By Number", Value="0", Selected=true}, new SelectListItem{ Text="Sort By Description", Value = "1" } })@{ var s = @ViewData["currentNode"];} @Convert.ToString(s) @foreach (SubSectionNodesVM n in Model.Nodes){ @if (n.CurrentNode.Key.Contains("Specification")) { Html.RenderPartial(T4MVC.SharedController.ViewNames._PrintButtons, n.CurrentNode); } var matchValue = n.Nodes as IEnumerable<sitemapnodebase>; var resultSet = from dtRow in matchValue.AsEnumerable() group dtRow by dtRow.Prefix into newGroup orderby newGroup.Key select newGroup; var datamodel = resultSet as IEnumerable<sitemapnodebase>; var k = 0; @foreach (var item in resultSet) { k++; var match = item.Select(m => m.DefaultValue); string resultDefaultValue = string.Empty; if (match != null) { if (match.Count() > 0) { resultDefaultValue = match.ToList()[0]; } } var i = 0; foreach (var inneritem in item) { k++; @if (@inneritem.RangeStart == null || @inneritem.RangeStart == "") { } else { } @if (@inneritem.RangeEnd == null || @inneritem.RangeEnd == "") { } else { } } } @resultDefaultValue @inneritem.NumberFrom: @inneritem.RangeStartTo: @[email protected] <script> $(document).ready(function () { $('#SortBy').change(function () { var value = $("#SortBy option:selected").val(); alert(value); }); }) </script> 解决方案 (document).ready(function () {('#SortBy').change(function () { var value =("#SortBy option:selected").val(); alert(value); }); }) </script> 这篇关于如何根据下拉列表中选择的值对表进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-18 09:55