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

Bug: Ajax filtering "endswith" does not work on text fields on my MVC project?

8 Answers 58 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.
Matthew
Top achievements
Rank 2
Matthew asked on 14 May 2010, 08:35 PM
Hey Folks,

So, I figured out my javascript parsing of wildcards, and I noticed something a little odd. I rolled my project back to the stock filtering and noticed something very odd. I can use ajax filtering to do startswith , contains, but endswith never works. It always returns 0 records.

This is using the standard filter control on the MVC Grid, and without any scripts or etc


I also tested my Repository/Model and I can use the .EndsWith from linq and get the correct results. not sure whats up.

Its probably something extremely silly, but I cant figure it out for the life of me.

My Model looks like this:
 
        [GridAction] 
        public ActionResult _AjaxBinding() 
        { 
             
            var items = inventory.GetItems(); 
 
            return View(new GridModel(items)); 
        } 
 
 
 
        public IQueryable<InventoryItem> GetItems() 
        { 
 
            //TODO: Make this into a view 
            var items = (from i in dataContext.tblItems where i.EffectiveEndDate > DateTime.Now 
                         select new InventoryItem {  
            Description = i.ItemDescription,             
            ID = i.ItemInternalID.ToString(),            
            PartNumber = i.ItemBarcodeID, 
            TotalQuantity = GetTotalQuantityByPartNumber(i.ItemBarcodeID) 
                          
            }); 
 
            return items; 
        } 
 
My controller:





I get 0 records returned when I attempt to do "endswith" if i use contains  or startswith, everything is great.

I cant for the life of me figure out why

Update: Turned off AJAX binding, everything works but "Ends With" filtering. :\ Not sure whats going on or why this would be the case. I'm using the 2010.1.309 scripts folder if that makes a difference.

8 Answers, 1 is accepted

Sort by
0
Matthew
Top achievements
Rank 2
answered on 14 May 2010, 09:23 PM
 
        [GridAction] 
        public ActionResult _AjaxBinding() 
        { 
 
            
                var items = inventory.GetItems(); 
                //items = (from i in items where i.PartNumber.EndsWith("INTE") select i); 
                GridModel gm = new GridModel(items); 
 
             try 
            { 
                IEnumerable<InventoryItem> blarg = (IEnumerable<InventoryItem>)gm.Data; 
 
                var ends = (from i in blarg where i.PartNumber.EndsWith("INTE") select i); 
 
                foreach (var b in ends) 
                { 
                    object o = b
                } 
 
                return View(new GridModel(items)); 
            } 
            catch(Exception ex) 
            { 
                object blarg = ex
                return View(new GridModel(items)); 
            } 
        } 
 
Did some more digging. Seems to be a LINQ  Query Issue.

I have the following block of code debugging this just to see if im getting any results.

Essentially when I use StartsWith or Contains(), i get results instantly and everything works great.

When I use EndsWith() the operation never completes, and times out

I tested it with the above code. Swatching the Partnumber... to StartsWith or EndsWith works fine. so i think this might have something to do with how the Grid/GridModel is interacting with my IQueryable<>. 

If I go up a level into my model and use .endswith() with link, everything works perfect, with no speed delay. This is a relatively small data set (6000 records in a view).

I think someone with far more linq knowledge than me needs to help me figure out whats going on here :)

0
Matthew
Top achievements
Rank 2
answered on 14 May 2010, 09:25 PM
Sorry to keep replying ot my own thread, but if I use .AsQueryable() in GridModel.Data, the query executes instantly.


Is there some way I can force my grid to use IQueryable instead of IEnumerable?

I guess I could extend GridModel?


0
Accepted
Atanas Korchev
Telerik team
answered on 15 May 2010, 08:13 AM
Hi Matthew,

The grid will use IQueryable if you pass one. The query will get executed when the grid starts rendering.

I am not sure why the query generated by the grid may cause a timeout. You can try making the query yourself to see if it will execute fine (no timeout). If it does I would ask you to open a support ticket and send us a sample project which shows the timeout. We will check it out and see what went wrong and why.

Regards,
Atanas Korchev
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
Matthew
Top achievements
Rank 2
answered on 17 May 2010, 03:56 PM
Thanks For your reply. 

Yes, I did try to do the .endswith filter in both the model and the controller, and it works fine with no timeout or other issues.

Only when I do it at the grid level.

In my model, I'm performing a LINQ query, and selecting into a IQueryable<MyCustomClass> collection.





>i Matthew,

>The grid will use IQueryable if you pass one. The query will get executed when the grid starts rendering.
>I am not sure why the query generated by the grid may cause a timeout. You can try making the query yourself to see if it will execute >fine (no timeout). If it does I would ask you to open a support ticket and send us a sample project which shows the timeout. We will >check it out and see what went wrong and why.

>Regards,
>Atanas Korchev 
>the Telerik team
0
Atanas Korchev
Telerik team
answered on 17 May 2010, 06:29 PM
Hello Matthew,

Then in must be a problem with the query generated by the grid. The expression should be something like this:

item => (item.Column?? "").ToLower().EndsWith("value".ToLower())

Is it possible to send us the relevant code in a support ticket? It would greatly help is in debugging.

Regards,
Atanas Korchev
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
Matthew
Top achievements
Rank 2
answered on 19 May 2010, 02:08 PM
What parts do you need, or do you want an entire project? I'll see if I cant create a project that illustrates this issue
0
Atanas Korchev
Telerik team
answered on 19 May 2010, 02:13 PM
Hello Matthew,

The simplest thing which reproduces the timeout will be enough - dummy data etc. Send the complete project only if you cannot reproduce it in a simple app.

Regards,
Atanas Korchev
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
Matthew
Top achievements
Rank 2
answered on 19 May 2010, 02:46 PM
EDIT: Sorry for wasting everyones time. Apparently this half-baked inventory solution was appending tons of whitespace in all records, and that was my issue. I use a .trim() and everything is fine.

Sorry !
Tags
Grid
Asked by
Matthew
Top achievements
Rank 2
Answers by
Matthew
Top achievements
Rank 2
Atanas Korchev
Telerik team
Share this question
or