This is a migrated thread and some comments may be shown as answers.

Client Side grid.Filter() doesn't work in Current release

18 Answers 365 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Asanka
Top achievements
Rank 1
Asanka asked on 15 Jul 2011, 11:31 AM
Hi,

I have downloaded the newest release of ASP.Net MVC Q2(2011.2.712) release. And then i upgraded my current solution (2011.1.315).
But as far as i can see client side filtering does not work. (But it is working properly as expected in 2011.1.315 release). The strange thing is that when i filter the data by clicking the filter icon in grid, it filters successfully, but not using client method grid.filter().

Any ideas???

Asanka

My code snippet:

var grid = $('#GridCompletedTrips').data('tGrid');
var filterstring = "";
filterstring = "PassengerCount~eq~2";
grid.filter(filterstring);  

18 Answers, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 15 Jul 2011, 01:38 PM
Hello Asanka,

Indeed, this is an issue with the current release. However, we have managed to address it and I have attached a build which contains the fix.

Greetings,
Rosen
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Ryan O'Neill
Top achievements
Rank 1
answered on 18 Jul 2011, 05:49 PM
This is also broken on your demo site;
http://demos.telerik.com/aspnet-mvc/razor/grid?theme=vista
0
Viliam
Top achievements
Rank 1
answered on 08 Aug 2011, 09:49 AM
I have some custom modifications to grid, 

can you also attach umninified version of the scripts, please?

Thanks.
0
Chris
Top achievements
Rank 1
answered on 19 Aug 2011, 12:51 PM
Hi, 
There is another a problem with this build. When no results are returned footer/pager part of the grid freezes (with invalid item count and pages).
Is there a build fixing this? 
0
Rosen
Telerik team
answered on 19 Aug 2011, 01:23 PM
Hi Mark,

Could you please provide a bit more information such a the view's declaration? Also please check if there are any javascript errors on the page.

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
jmarmash
Top achievements
Rank 1
answered on 26 Oct 2011, 07:19 PM
Hello -

I too experienced this issue and when I applied the hotfix, the issue was resolved...  Great!  However, I am working on a large team in a CI environment.  I *could* write some sort of custom script to handle the hotfix until the next full release is available but, I was wondering if it would be possible to have a Nuget package for the hotfix.  This would greatly simplify our development environments and builds and make applying hotfixes much simpler going forward.

Thoughts?

Thanks in advance,
Jeff
0
Bart
Top achievements
Rank 1
answered on 31 Oct 2011, 11:29 AM
I noticed that the grid.Filter() only works if you don't change the operationmode. When I choose GridOperationMode.Client the filter no longer is applied. Are there any plans to change this behavior?

Bart
0
gm
Top achievements
Rank 1
answered on 14 Feb 2012, 10:38 PM
"I noticed that the grid.Filter() only works if you don't change the operationmode. When I choose GridOperationMode.Client the filter no longer is applied."

I couldn't figure out why my grid.Filter() wasn't working and fortunately ran across your comment!

I would also like to know if there is any plan to change this behavior?
0
Arthur
Top achievements
Rank 1
answered on 15 Feb 2012, 12:53 PM
I'm using the MVC Q3 2011 SP1 (2011.3.1306) release. (I couldn´t make the hotfix work) 

I'm also trying to make a personalized filter, something similar to the date range of Telerik Ajax Filter Template ( http://demos.telerik.com/aspnet-ajax/grid/examples/programming/filtertemplate/defaultcs.aspx )

here is my View:

Html.Telerik().Grid<Bilhete>()
    .Name("bGrid")
    .Columns(columns =>
                {
         columns.Bound(o => o.NumeroDestino);
         columns.Bound(o => o.DataChamada);
         columns.Bound(o => o.DuracaoOriginal);
         columns.Bound(o => o.ValorOriginal);
         columns.Bound(o => o.Localidade);
    })
    .DataBinding(u => u.Ajax().OperationMode(GridOperationMode.Client)
          .Select("SelectBilhete", "Tel", new {batchId = Model.BatchId, userCode = Model.UserCode, planoId = Model.PlanoId }))
    .Sortable()
    .Pageable(pager => pager.PageSize(10).Style(GridPagerStyles.NextPreviousAndInput))

And using Chrome's Inspect element, I have a console to run javascript: (so I can test it)
var grid = $('#bGrid').data('tGrid');
grid.filter("NumeroDestino~eq~1019");
> TypeError: Object #<Object> has no method 'filter'

Am I doing something wrong?
0
Rosen
Telerik team
answered on 15 Feb 2012, 01:43 PM
Hello Gregg,

Indeed, setting filter when client operation mode is enabled is currently not supported. However, this can be workaround to a degree by manually parsing the filter expression and assigning it to the DataSource component of the grid. I have attached a modified version of this CodeLibrary which demonstrates a possible implementation. 

Regards,
Rosen
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
gm
Top achievements
Rank 1
answered on 15 Feb 2012, 02:21 PM
Thanks, Rosen - I'll give that a try.
0
gm
Top achievements
Rank 1
answered on 15 Feb 2012, 02:24 PM
Arthur,

How is the JavaScript code you posted called?  For example, is it in an event handler?

Update: Try and add .Filterable() to your grid and see if you still get the JavaScript error.

0
Arthur
Top achievements
Rank 1
answered on 15 Feb 2012, 07:20 PM
Thanks all for the help,

Gregg, I just tried to add .Filterable() and it didn't return an error, but the filter didn't work that way.

Rosen, that worked GREAT,  the grid.dataSource.filter really did the trick, but how can I do a between filter? (greater than and lower than)
like:  grid.filter("field~ge~10255~field~le~29103");

I would like to do something like this:

dataSource.filter([
        { field: "Price", operator: "ge", value: 3.14 },
        { field: "Price", operator: "le", value: 42 }
]);

but this will not work
0
Arthur
Top achievements
Rank 1
answered on 15 Feb 2012, 07:44 PM
I just found how to do it :)

var grid = $('#bGrid').data('tGrid');
var A = new Array();
 A.push({ field: "Price", operator: "ge", value: 3.14 });
 A.push({ field: "Price", operator: "le", value: 42 });
 grid.dataSource.filter(A);

Thanks a lot Gregg and Rosen :)

-----
Just for the record, I had to add grid.columns[columnumber].filters to the pagination be able to work as it is suppose to.

Here is an example of how it is done:

var grid = $('#bGrid').data('tGrid');
var A = new Array();
 A.push({ field: "Price", operator: "ge", value: 3.14});
 A.push({ field: "Price", operator: "le", value: 42 });
 grid.dataSource.filter(A);
 
grid.columns[1].filters = (grid.columns[1].filters || []);
grid.columns[1].filters.push({ operator: "ge", value: 3.14 });
grid.columns[1].filters.push({ operator: "le", value: 42 });

I hope this can be useful to anybody who also needs it.
0
Szilard
Top achievements
Rank 1
answered on 20 Mar 2012, 02:49 PM
Hello,

Is this issue still present in the 2012 Q1 release (version 2012.1.214.0)?
0
sathish kumar
Top achievements
Rank 1
answered on 26 Mar 2012, 02:23 PM
Hi Rosen,

i tried ur sample project and it works great!!!

Although if the operator in filter is selected as 'endswith' and if u tyr to filter unexpected results are returned. For instance if the value for the 'endswith' operator is set as say a 'n' letter word, it returns the result as well as data which are (n-1) letter long if there are any. This behaviour is also found in the online demos (for client operation mode filtering). i made a change in ur js file to test this and i was able to reproduce the same issue. Please find the details in the attachment files. Could you please suggesta workaround for this issue.

Regards,
Sathish
0
David
Top achievements
Rank 1
answered on 20 Mar 2013, 03:10 PM
Hi Arthur,

Thanks for your solution, it worked for me as well! One thing, though, and apologies if this has been asked before (I can't seem to find it if it has), is it possible to actually update the filter icon and the values that come up when you click the filter icon for your column? I'm loading the filters from the database and at the moment I can filter it but there is no visual to show that there is currently an active filter, so the user won't know they're not seeing all the data. I want to avoid a custom solution if there's one built in!

Thanks!
0
David
Top achievements
Rank 1
answered on 20 Mar 2013, 04:42 PM
Never mind, it seems it was a typo, I tried to set the filter to 'substringOf' but when I changed it to a lowercase 'o' it worked! I had to change the filter icon to show 'active' manually though (I added a custom data attribute to identify each column separately):

$('[data-columnname="ContactName"] .t-grid-filter').addClass('t-active-filter')

Works like a charm!
Tags
Grid
Asked by
Asanka
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Ryan O'Neill
Top achievements
Rank 1
Viliam
Top achievements
Rank 1
Chris
Top achievements
Rank 1
jmarmash
Top achievements
Rank 1
Bart
Top achievements
Rank 1
gm
Top achievements
Rank 1
Arthur
Top achievements
Rank 1
Szilard
Top achievements
Rank 1
sathish kumar
Top achievements
Rank 1
David
Top achievements
Rank 1
Share this question
or