This question is locked. New answers and comments are not allowed.
Hi there,
I am using a teleric grid for my MVC application.
I am displaying the data in grid too..
I need to display the details in descending order i.e., the most recent rows in the content history table has to be displayed.
I am using the code as follows:( The bold ones)
[GridAction]
public ActionResult _GetHistory(int? ID)
{
if (ID.HasValue)
{
var id = from c in _DataContext.ApplicationLabels
where c.ID == ID
select c;
ApplicationLabel applable = id.First();
var history = from h in _DataContext.ContentHistories
where h.Modified <= DateTime.Now
orderby h.Modified descending
select new HistoryViewModel
{
Name = h.Terminology.Name,
Data = h.Data,
Modified = h.Modified,
UserName = h.aspnet_Users.UserName
};
return View(new GridModel
{
Data = history.OrderByDescending(o => o.Modified)
});
}
else
{
var history = from h in _DataContext.ContentHistories
where h.Modified <= DateTime.Now
select new HistoryViewModel
{
Name = h.Terminology.Name,
Data = h.Data,
Modified = h.Modified,
UserName = h.aspnet_Users.UserName
};
return View(new GridModel
{
Data = history.OrderByDescending(o=>o.Modified).ToList()
});
view.aspx:
<p>
Orders:
<%= Html.Telerik().Grid<ResourceKit.Models.HistoryViewModel>()
.Name("ContentHistory")
.DataBinding(binding => binding.Ajax().Select("_GetHistory", "Application"))
.Columns(column =>
{
column.Bound(ch => ch.Name);
column.Bound(ch => ch.Data).Title("Data");
column.Bound(ch => ch.Modified).Title("Modified");
column.Bound(ch => ch.UserName).Title("UserName");
}).Pageable().Sortable()
%>
</p>
Please let me know what changes has to be made inorder to display the details in descending order by default.
Thanks,
Lavanya
I am using a teleric grid for my MVC application.
I am displaying the data in grid too..
I need to display the details in descending order i.e., the most recent rows in the content history table has to be displayed.
I am using the code as follows:( The bold ones)
[GridAction]
public ActionResult _GetHistory(int? ID)
{
if (ID.HasValue)
{
var id = from c in _DataContext.ApplicationLabels
where c.ID == ID
select c;
ApplicationLabel applable = id.First();
var history = from h in _DataContext.ContentHistories
where h.Modified <= DateTime.Now
orderby h.Modified descending
select new HistoryViewModel
{
Name = h.Terminology.Name,
Data = h.Data,
Modified = h.Modified,
UserName = h.aspnet_Users.UserName
};
return View(new GridModel
{
Data = history.OrderByDescending(o => o.Modified)
});
}
else
{
var history = from h in _DataContext.ContentHistories
where h.Modified <= DateTime.Now
select new HistoryViewModel
{
Name = h.Terminology.Name,
Data = h.Data,
Modified = h.Modified,
UserName = h.aspnet_Users.UserName
};
return View(new GridModel
{
Data = history.OrderByDescending(o=>o.Modified).ToList()
});
view.aspx:
<p>
Orders:
<%= Html.Telerik().Grid<ResourceKit.Models.HistoryViewModel>()
.Name("ContentHistory")
.DataBinding(binding => binding.Ajax().Select("_GetHistory", "Application"))
.Columns(column =>
{
column.Bound(ch => ch.Name);
column.Bound(ch => ch.Data).Title("Data");
column.Bound(ch => ch.Modified).Title("Modified");
column.Bound(ch => ch.UserName).Title("UserName");
}).Pageable().Sortable()
%>
</p>
Please let me know what changes has to be made inorder to display the details in descending order by default.
Thanks,
Lavanya