2017-02-14 1 views
1

확인란을 선택하면 검도 UI 텍스트 편집기를 표시하려고했습니다. 그것이 작동하지 않습니다 그러나
, 당신은/그 렌더링 화면의 초기로드에 Model.IsAlert을 평가합니다 .. 교체 아웃kendoui 텍스트 편집기가있는 면도기

@if (Model.IsAlert!=true) 
{ 
    <td>     
    @(Html.Kendo().Editor().Name("Explanation").HtmlAttributes(new { style = "display:show" }))    
    </td> 
} 
+0

당신의 현재 접근 방식은 화면 초기로드시 Model.IsAlert! = true만을 평가할 것입니다 ... 대신 값을 기반으로 텍스트 상자를 숨기거나 표시하기 위해 일부 javascript/jquery를 구현할 수 있습니까? –

+1

당신 Dinglemeyer somuch 고맙습니다, 당신의 승인은 지금 일하고 있습니다 ... :) – Radha

+0

그것이 작동하는 경우, 그것을 대답으로 표시 자유롭게 주시기 바랍니다 :) 다행있어 다행! –

답변

0

현재 방법을 나에게 도움이 될 수 있습니다.

if 문을 제거하고이 td를 숨김으로 기본 설정 한 다음 확인란 컨트롤에 매핑 된 onChange 이벤트 처리기를 통해 모델의 속성에 따라 변경하는 것이 좋습니다.

<td id="thingToHide" hidden="hidden"> 
@(Html.Kendo().Editor().Name("Explanation").HtmlAttributes(new { style = "display:show" }))    
</td> 

일부 jQuery 코드 :

<script type="text/javascript"> 
$(document).ready(function() { // On page load method, check model and show textbox if needed 
     var model = @Html.Raw(Json.Encode(Model)); // get model example is taken from http://stackoverflow.com/questions/16361364/accessing-mvcs-model-property-from-javascript 
     if (model.IsAlert) { // If model IsAlert is true, show Explanation field 
      $("#thingToHide").show(); 
     } 
}); 

$("#YourCheckBoxId").on("change", function() { 
    $("#thingToHide").toggle(); 
}); 
</script> 

행운을 빌어 요 라다!

+0

답장을 보내 주셔서 대단히 감사합니다. 이런 식으로 쓸 수 있습니까? 검도와 면도기를 처음 접했을 때 .HtmlAttributes (new {condition}) ...에 조건을 쓸 수 있는지 의심 스럽습니다. .................. @ (Html.Kendo(). EditorFor (model => model.Explantion) .HtmlAttributes (new {@ style = Model.IsAlert? "display : show white-space : pre ":"display : none "})) 작동합니까? – Radha

+0

나는 @style이 있어야 할 필요가 있다고 생각한다. 각 스타일 사이에 나열되어 있으므로 "display : show; white-space : pre;" 어떻게 그 부분을 포맷하고 싶을 것입니다. 그것을 밖으로 시도하십시오 !! :) –

관련 문제