Telerik RadComboBox in a RadGrid Client Side Validation
I'm using the Telerik ASP.net control suite (2008 Q3 I believe, can't upgrade yet). I've got a radcombobox in a Radgrid control (in a GridT开发者_如何学GoemplateColumn's Edit template). If functions ok, but I've got some client side validation on other controls on the grid (that appear to be working without errors). For some reason after the client side validation happens, the combo box stops functioning. No visible js errors, the thing just dies.
Anyone seen this and have fix? Google has failed me.
Thanks for your help.
Ok, I solved it. Very cludgy work around.
First, I've got a panel outside of the multiviewpanel that holds my grid with another similar Radcombobox that also died on validation. I started thinking, what if I did some sort of post back, would that fix things for some reason? So in my grid I added a custom validator that validates the RadComboBox in my grid. It calls a javascript validation method like so...
function valCOMBO(o, a) {
a.IsValid = true;
setTimeout(Res, 500);
}
function Res() { __doPostBack("<%=OPCOCombo.UniqueID %>");}
Note, since this field isn't required to be filled in by the user, I always return is valid is true. Here is where the quasi magic happens. I make a post back on the OTHER RadComboBox in the top panel outside the grid in javascript. The top out of grid RadComboBox has its autopostback set to true, don't know if that is necessary if you try this example.
It worked. All of a sudden both RadComboBoxes, both the one in the grid and the one above it started working again. But I noticed the value would be lost in the grid's RadComboBox sometimes, so for giggles I added the slight pause before doing the post back of 500 ms. That did the trick. It actually would work with a very small pause, but I increased it to 500 ms for a saftey margin incase an end user was on a slow connection and that might matter.
Cluggy, cluggy, cluggy. I wish I could have just used jQuery, and used an alternative to these freaking telerik radcomboboxes, but such is life (I hear a limited version of jQuery is burried in Telerik, will experiment with that on later releases). What sucks is I bet the latest release of Telerik fixes this problem (it better), so all this poking around will end up being unnecessary when we upgrade (can't yet, some conflict with some of the customized controls that we build inheriting off of Telerik. Jan Q1 2009+ break those controls :( )
Hope this might help someone.
Another option. I ran into a scenario where I had to use lots of RadComboboxes so rather then worry about validating their contents, I just added text fields with a button next to each one that would open a radwindow with a RadComboBox so values could be chosen dynamically. On select javascript passed the selectedvalue back to the target element on the window opener page. I ran into a few headaches that I had to work though with having a bunch of context parameters set in javascript before calling the webservice on each key up (hint: with IE set the height of Radcombobox at least for 2008 Telerik versions...if you don't you will start having freezes).
Again, hope this idea is useful.
精彩评论