Another story in what it’s really like to develop software. These are the kinds of hacky bodges you will end up making in any system that is more than a few months old and is in production. 🙁 These hacks do not make me happy. Especially when they are hacked because of pre-built components that are meant to save you time!
The Telerik Radgrid is both a blessing and a curse at the same time. How can a grid, that seems designed to have a dropdown column in it and comes with default filtering, not take into account the fact that you are going to have foreign keys in a grid that you want to filter on?
This is an ongoing rant of mine. Getting good foreign key support on large enterprise applications seems like an uphill struggle every single time. I wrote about how I like to see books on programming jump right in and show me how to get my foreign key drop downs hooked up almost right off the bat, since it is almost entirely unavoidable in any application that has any sort of usefulness in my opinion.
My goodness getting the RadGrid to do your bidding can be an infuriating ride. Personally, I think components should just work out of the box. I know the RadGrid is extremely complex and there are layers upon layers of documentation and examples on the Telerik site, but to me, I shouldn’t have to find out about how difficult it is to filter on ListTextField after I’ve knocked up a prototyped to a client. Heck the documentation should have a large caveat at the top telling you the limitation of the software. Really, I shouldn’t need to read that far into the documentation just to use the component in my opinion. I want something quick and easy to take the pain out of grid based data admin, not a whole new bloody thing that I have to learn inside out.
As per Telerik’s website:
he built-in GridDropDownColumn will be filtered by its ListValueField when the default filtering feature of the control is used. Filtering by ListTextField is not attainable in the present version of Telerik RadGrid
Great. Thanks! This is burried in the How To section. Okay, not too obtuse, but still, all the basic examples show filtering on example datasets that are things like Customer listings (with Customer, Contact Name, Company). Heck, it is reasonable to assume that Company was being looked up using the GridDropDownColumn column. Isn’t it?
So, Telerik provide a solution – have a hidden field that is the text description. Capture the ItemCommand on the grid and then if it is a filter command, pop the filter text into the hidden field’s filter text box and run the filter based on that criteria. The problem is, out of the box this breaks user experience because the filter text they typed in disappears.
Now you have to hack around to find a way to keep the filter text there. Come on Telerik, get this one together. Not pleasant. I gave up, because I didn’t have time to delve that deeply into the RadGrid. I needed something quicker. Option 2 given by Telerik – implement a custom drop down in the actual filter area of the grid. The example code was long and I didn’t feel like going through it – again time constraints. I just couldn’t spend time exploring all of this because I have deadlines. Why couldn’t they just build this into the grid? If they have solutions, it shouldn’t be that difficult to put it into the base functionality.
One more thing – putting a drop down in that is based on an id field (and let’s be honest it probably is if it’s a lookup into another table) means you get the default “number” filtering options. This means that the filtering options out of the box are things like “greater than”, “less than” etc etc. These don’t make sense for a user who is filtering based on text. This is another fault with their default solution outlined above of using the hidden field and substituting values in. I know you can overide this and put your own filtering menu in, but say it with me…..deadlines. 🙁
By now, I’m not a happy bunny. What did I do in the end? I amended my stored proc to bring back a complete result set with description fields (making things slower for me because now I have table joins). Then I hid the drop down list field until the user wanted to edit the row or add a new row in. Then I hid the description fields and showed the drop down fields.
What a bodge.