2015-01-12 18 views
0

我有MVC 5次与一个或多个Telerik的数字文本框,每个渲染,如:jQuery的选择Telerik的数字文本框的值的

<span class="k-widget k-numerictextbox"> 
<span class="k-numeric-wrap k-state-default"> 
    <input tabindex="0" class="k-formatted-value k-input" aria-disabled="false" aria-readonly="false" style="display: inline-block;" type="text"> 
    <input name="SelectedMinimumChange" class="k-input" id="SelectedMinimumChange" role="spinbutton" aria-disabled="false" aria-readonly="false" aria-valuenow="10" aria-valuemin="5" aria-valuemax="95" style="display: none;" type="text" min="5" max="95" step="5" value="10" data-role="numerictextbox"> 
    <span class="k-select"> 
     <span class="k-link" style="-ms-touch-action: double-tap-zoom pinch-zoom;" unselectable="on"> 
      <span title="Increase value" class="k-icon k-i-arrow-n" unselectable="on">Increase value 
      </span> 
     </span> 
     <span class="k-link" style="-ms-touch-action: double-tap-zoom pinch-zoom;" unselectable="on"> 
      <span title="Decrease value" class="k-icon k-i-arrow-s" unselectable="on">Decrease value 
      </span> 
     </span> 
    </span> 
</span> 

我的任务是让所选择的值(S ),这是在第二输入标签,在属性“值”(该样品是在10保持)和隐藏控件

获取控制是很容易(甚至对我来说):

$(".k-numerictextbox").each(function() { 
     var control = $(this); 
     …  try to get the value 
     Control.hide(); 
}); 

这找到并隐藏控件。我可以得到具体的控制与价值:

var displayVal = input.data("kendoNumericTextBox").value() 

但没有工作我尝试串起来够jQuery选择。我需要从控件去类“k-输入”(有2)的孩子,然后具有[数据角色] ='数字文本框'属性的孩子,然后在那里获取属性值的值。我试过[很多东西]每个循环中 - 我的最后:

var displayVal = control.children(".k-input").find("[data-role]='numerictextbox'") 

感觉就像是在正确的轨道上,但我想不出是谁的下一个选择,以获得结果添加。

感谢, 斯科特

回答

0

决定由内而外去 - 这里是什么工作:

 $("input[type=text][id][data-role=numerictextbox]").each(function() { 
     var input = $(this); //the element within the numerictextbox with the id 
     var id = input.attr("id"); //get the id 
     var control = $("#" + id).data("kendoNumericTextBox"); //get the kendo control from the id 
     var displayVal = control.value(); //the value we want to display 
     var displayElem = $("<span />"); //new display element 
     displayElem.text(displayVal); 
     var topControlElement = input.closest(".k-numerictextbox"); //get the root element making up the kendo numerictextbox 
     displayElem.insertBefore(topControlElement); 
     control.destroy(); 
     topControlElement.remove(); 
    });