简体   繁体   English

RadGrid客户端验证中的Telerik RadComboBox

[英]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). 我正在使用Telerik ASP.net控制套件(我认为是2008 Q3,尚无法升级)。 I've got a radcombobox in a Radgrid control (in a GridTemplateColumn's Edit template). 我在Radgrid控件(在GridTemplateColumn的Edit模板中)中有一个radcombobox。 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. 没有可见的js错误,事情就死了。

Anyone seen this and have fix? 任何人都看到并修复了吗? Google has failed me. Google让我失败了。

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. 首先,我在multiviewpanel之外有一个面板,该面板将我的网格与另一个类似的Radcombobox保持在一起,该Radcombobox也在验证时失效。 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. 因此,在网格中,我添加了一个自定义验证器,用于验证网格中的RadComboBox。 It calls a javascript validation method like so... 它调用像这样的javascript验证方法...

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. 注意,由于用户不需要填写此字段,因此我总是返回true是否为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. 我在javascript网格上方的顶部面板中的OTHER RadComboBox上发了一个帖子。 The top out of grid RadComboBox has its autopostback set to true, don't know if that is necessary if you try this example. 网格顶部的RadComboBox的autopostback设置为true,如果尝试此示例,则不知道是否有必要。

It worked. 有效。 All of a sudden both RadComboBoxes, both the one in the grid and the one above it started working again. 突然,两个RadComboBoxes(网格中的一个及其上方的两个)再次开始工作。 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. 但是我注意到该值有时会在网格的RadComboBox中丢失,因此,为咯咯地笑,我在执行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. 它实际上可以停顿很小的时间,但是如果最终用户的连接速度很慢,我可以将其增加到500 ms,以提高安全性,这可能很重要。

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). 我希望我能使用jQuery,并使用这些怪异的telerik radcomboboxes的替代品,但这就是生活(我听说Telerik中埋藏了jQuery的有限版本,将在以后的发行版中进行尝试)。 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 :( ) 糟糕的是,我敢打赌,Telerik的最新版本解决了这个问题(更好),因此,当我们升级时,所有这些戳戳最终都将是不必要的(目前还不能与我们继承来的一些自定义控件冲突) of Telerik。Jan Q1 2009+打破了这些控制:()

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. 我遇到了不得不使用大量RadCombobox的情况,因此不必担心验证其内容,我只是在每个文本框旁边添加了一个带有按钮的文本字段,这将打开一个带有RadComboBox的radwindow,因此可以动态选择值。 On select javascript passed the selectedvalue back to the target element on the window opener page. 在选择javascript时,将selectedvalue传递回窗口打开器页面上的目标元素。 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). 我遇到了一些麻烦,尽管必须在JavaScript上设置一堆上下文参数,然后才能在每个按键上调用Web服务之前工作(提示:使用IE至少应设置2008 Telerik版本的Radcombobox的高度...如果您不会,您将开始冻结)。

Again, hope this idea is useful. 再次,希望这个想法有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM