This question is locked. New answers and comments are not allowed.
Hi,
Is there any way to have the mvc grid either highlight the column header or change the filter icon on columns the grid is filtered on when setting filter in java script?
Ken Tucker
Is there any way to have the mvc grid either highlight the column header or change the filter icon on columns the grid is filtered on when setting filter in java script?
Ken Tucker
6 Answers, 1 is accepted
0
Hi,
Rosen
the Telerik team
In order filtered column's icon to be highlighted when setting the filter expression through the client-side API, you should also manually set the column's filters. For example:
function
myFilterFunction() {
var
grid = $(
'#Products'
).data(
'tGrid'
);
var
filter =
'Id~eq~2'
;
var
column = grid.columnFromMember(
"Id"
);
if
(column) {
column.filters = [filter];
}
grid.filter(filter);
}
Rosen
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
vb2ae
Top achievements
Rank 1
answered on 14 Dec 2010, 08:56 PM
This is not working in the 2010 Q2 version I am using now. Do I need to upgrade to the 2010 Q3 release?
I did have to change your code a little. The main change is the grid.AjaxRequest().
I did have to change your code a little. The main change is the grid.AjaxRequest().
function onLoad(e) {
var grid = $(this).data('tGrid');
$.get('/AQGrid/GetFilterState/', function (data) {
if (data) {
var mySplitResult = data.split("~");
var column = grid.columnFromMember(mySplitResult[0]);
if (column) {
column.filters = [data];
}
grid.filterBy = data;
grid.ajaxRequest();
}
});
grid.ajaxRequest();
$.get('/AQGrid/GetSortOrder/', function (data) {
if (data) {
grid.orderBy = data;
grid.ajaxRequest();
}
});
}
Ken
0
Hello vb2ae,
Rosen
the Telerik team
I'm afraid that I'm not sure what is your exact scenario, therefore it will be appreciated if you could sent us a small runnable project.
All the best,Rosen
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
vb2ae
Top achievements
Rank 1
answered on 15 Dec 2010, 02:20 PM
Basically I when a user leaves the grid I am storing the sort order and filter in session state. When the user returns to the grid I get the last filter from the controller and apply it to the grid. I was trying to get the filter icon to highlight for the filtered column when the filter is set in javascript. Here is a real simple sample of what I am doing
0
Accepted
Hello vb2ae,
Rosen
the Telerik team
I have looked at the project you have send us. The reason for the filter icon not to be highlighted is the fact that columnFromMember method is case sensitive and you are passing member name with different casing. Also you will need to use filter method instead of ajaxRequest.
Regards,Rosen
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
vb2ae
Top achievements
Rank 1
answered on 16 Dec 2010, 12:18 PM
Ok thanks