Hi
I am using Telerik(Product Version 2012.3.1018.340) MVC grid for my project. When I am setting initial Sort configuration with multiple columns, It have an issue with individual column sorting. The individual column sorting is not at all working in my grid
It is working fine if I didn't set initial sort order (ie, if i give just ".sortable()"). But i want to set initial sort order also individual column sort order functionality
I tried with operation mode is client. Then for one time the sorting is happening only for anyone column which we clicked first. Next time when we try to click on any other column to sort it won't work.
I used the following code in my project, please help me to tackle this issue
view
------
controller
----------
I am using Telerik(Product Version 2012.3.1018.340) MVC grid for my project. When I am setting initial Sort configuration with multiple columns, It have an issue with individual column sorting. The individual column sorting is not at all working in my grid
It is working fine if I didn't set initial sort order (ie, if i give just ".sortable()"). But i want to set initial sort order also individual column sort order functionality
I tried with operation mode is client. Then for one time the sorting is happening only for anyone column which we clicked first. Next time when we try to click on any other column to sort it won't work.
I used the following code in my project, please help me to tackle this issue
view
------
Html.Telerik().Grid<MyApplication.MainApplication.Models.ApplicationModel.ApplicationViewModel>().Name(
"Grid1"
)
.Columns(col =>
{
col.Bound(c => c.UserID).ClientTemplate(
"<a href='"
+ Url.Content(
"~/Index/Details/"
) +
"<#= UserID #>' title='Details' class='lnkDetails'><#= Number #></a>"
).Title(
"Number"
).Filterable(
false
);
col.Bound(c => c.FirtName).Filterable(
false
);
col.Bound(c => c.LastName).Filterable(
false
);
col.Bound(c => c.RID).Hidden();
col.Bound(c => c.Active).Filterable(
false
).ClientTemplate(
"<input type='checkbox'"
+
"<#= Active?\"checked\":\"\" #>"
+
" OnClick='return false' />"
).Width(115);
col.Bound(c => c.StartDate).Filterable(
false
).Format(
"{0:d}"
).Width(115);
col.Bound(c => c.CloseDate).Filterable(
false
).Format(
"{0:d}"
).Width(112);
if
(currentUser.AdminRole && (currentUser.DataRole || currentUser.StaffRole))
{
col.Bound(c => c.ID).ClientTemplate(
"<a href='"
+ Url.Content(
"~/Controller/Create/"
) +
"<#= UserID #>' title='New Contact' class='edit'>New Contact</a>"
+
"<a href='"
+ Url.Content(
"~/Controller/Details/"
) +
"<#= UserID #>' title='Details' class='details action-margin'>Edit</a>"
+
"<a href='"
+ Url.Content(
"~/Controller/Delete/"
) +
"<#= UserID #>' title='Delete' class='delete action-margin'>Delete</a>"
).Title(
"Action"
).Filterable(
false
).Sortable(
false
).Width(90);
}
else
if
(currentUser.AdminRole)
{
col.Bound(c => c.UserID).ClientTemplate(
"<a href='"
+ Url.Content(
"~/Controller/Details/"
) +
"<#= UserID #>' title='Details' class='details'>Edit</a>"
+
"<a href='"
+ Url.Content(
"~/Controller/Delete/"
) +
"<#= UserID #>' title='Delete' class='delete action-margin'>Delete</a>"
).Title(
"Action"
).Filterable(
false
).Sortable(
false
).Width(90);
}
else
{
col.Bound(c => c.UserID).ClientTemplate(
"<a href='"
+ Url.Content(
"~/Controller/Details/"
) +
"<#= UserID #>' title='Details' class='details action-margin'>Edit</a>"
).Title(
"Action"
).Filterable(
false
).Sortable(
false
).Width(75);
}
})
.DataBinding(dataBinding => dataBinding.Ajax().Select(
"_Index"
,
"Controller"
))
.Pageable(p => p.PageSize(30))
.Filterable(f => f.Filters(filters =>
{
filters.Add(c => c.Number).StartsWith((
string
)ViewData[
"Number"
]);
filters.Add(c => c.FirstName).StartsWith((
string
)ViewData[
"FirstName"
]);
filters.Add(c => c.LastName).StartsWith((
string
)ViewData[
"LastName"
]);
}))
.Sortable(sorting => sorting
.Enabled(
false
)
.SortMode(GrUserIDSortMode.MultipleColumn)
.OrderBy(sortOrder =>
{
sortOrder.Add(o => o.Number);
sortOrder.Add(o => o.FirstName);
sortOrder.Add(o => o.LastName);
sortOrder.Add(o => o.Active);
sortOrder.Add(o => o.StartDate).Descending();
sortOrder.Add(o => o.CloseDate).Descending();
sortOrder.Add(o => o.UserID);
}))
.Render();
controller
----------
[GridAction]
public
ActionResult _Index()
{
return
View(
new
GridModel<UserViewModel>
{
Data = GetCases().ToList()
});
}