Hallo,I have a problem by sorting date in grid. The format of the date is "dd/MM/yyyy hh:mm:ss" and sorting doesn't work correct.
Part of the code:
public class ProductModel { public string Name { get; set; } public DateTime StartTime { get; set; } public DateTime EndTime { get; set; } }
public ActionResult User() { List<ProductModel> products = new List<ProductModel>();
products.Add(new ProductModel() { Name = "Milk", StartTime = new DateTime(2013, 6, 1, 11, 22, 22), EndTime = new DateTime(2013, 6, 20, 12, 12, 22) }); products.Add(new ProductModel() { Name = "Water", StartTime = new DateTime(2013, 12, 4, 1, 12, 24), EndTime = new DateTime(2014, 6, 1, 11, 22, 22) }); products.Add(new ProductModel() { Name = "Banana", StartTime = new DateTime(2011, 3, 24, 13, 2, 22), EndTime = new DateTime(2013, 6, 1, 11, 22, 22) }); products.Add(new ProductModel() { Name = "Tomato", StartTime = new DateTime(2011, 2, 14, 13, 2, 52), EndTime = new DateTime(2013, 6, 1, 11, 22, 22) }); return View(products.AsQueryable()); }
@model IQueryable<GridTesting.Models.ProductModel>@using Infragistics.Web.Mvc
@{ ViewBag.Title = "User";}
@(Html.Infragistics() .Loader() .ScriptPath(Url.Content("~/Content/ig/js/")) .CssPath(Url.Content("~/Content/ig/css/")) .Resources("igGrid.Selection,igGrid.Paging,igGrid.Sorting") .Theme("metro") .Locale("bg") .Regional("bg") .Render() )
<h2>User</h2>
<div class="searchArea">
<table id="grid"></table> @(Html.Infragistics().Grid(Model).ID("grid") .FixedHeaders(false).FixedFooters(false) .JQueryTemplating(true) .AutoGenerateColumns(false) .RenderCheckboxes(true) .Columns(column => { column.For(x => x.Name).HeaderText("ID").DataType("string").Width("120px"); column.For(x => x.StartTime).HeaderText("StartTime").Format("dd/MM/yyyy hh:mm:ss").DataType("date").Width("150px"); column.For(x => x.EndTime).HeaderText("EndTime").Format("dd/MM/yyyy hh:mm:ss").DataType("date").Width("150px"); })
.Features(features => { features.Sorting().Type(OpType.Local).Mode(SortingMode.Single).FirstSortDirection("ascending").ApplyColumnCss(false); features.Paging().Type(OpType.Local).PageSize(10).ShowPageSizeDropDown(false) .ShowPagerRecordsLabel(false) .VisiblePageCount(3) .PrevPageLabelText("") .NextPageLabelText("") .ShowFirstLastPages(false); features.Tooltips() .Visibility(TooltipsVisibility.Always) .ColumnSettings(settings => { settings.ColumnSetting().ColumnKey("ConsumerName").AllowTooltips(true); settings.ColumnSetting().ColumnKey("StartTime").AllowTooltips(true); settings.ColumnSetting().ColumnKey("EndTime").AllowTooltips(false); }) .CursorTopOffset(10) .ShowDelay(100); features.Resizing().AllowDoubleClickToResize(true).DeferredResizing(true).ColumnSettings(settings => { settings.ColumnSetting().ColumnKey("ConsumerName").MinimumWidth(140); settings.ColumnSetting().ColumnKey("StartTime").MinimumWidth(140); settings.ColumnSetting().ColumnKey("EndTime").MinimumWidth(140); }); features.Selection().Mode(SelectionMode.Row).MultipleSelection(false); }).Width("940").DataBind().Render()) </div>
Hello Marylka ,
I succeeded in reproducing the mentioned issue still it seems to be fixed in our latest service release, therefore I could suggest you upgrade to our latest service release. You can download it from the following link:
https://ko.infragistics.com/my-account/keys-and-downloads/
just click over your product key and go to the tab “Service releases”.
Please let me know if you need any additional information on this matter.
Hello Marylka,
I am still following your case. have you been able to resolve your issue?
Please feel free to contact me if you have any additional questions regarding this matter.