This is a migrated thread and some comments may be shown as answers.

Custom Popup Edit Template troubles

1 Answer 34 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ed
Top achievements
Rank 1
Veteran
Ed asked on 29 Jan 2020, 02:15 PM

Hi,

I have a template that I want to display certain controls if I am editing and others if I am creating new.

I have the code shown below but it does not work. It seems that the template is initialized at the time the parent is loaded.

How can I display the dropdown list in create mode and the textbox in edit mode?

The code below doesn't work but shows what I am trying to do. 

Thanks … Ed

 

<div class="form-group">
    <label class="LabelStyle">Vial</label>
    @{
        if (Model != null && Model.IsCreatingNew)
        {
            @(Html.Kendo().DropDownListFor(m => m.VialId)
            .AutoBind(true).DataValueField("VialId").DataTextField("VialName")
            .DataSource(source =>
                                {
                                    source.Ajax()
                        .Read(r => { r.Url("?handler=VialsRead").Data("forgeryToken"); });
            }).HtmlAttributes(new { style = "width:150px" }))
            <span asp-validation-for="VialId" class="text-danger"></span>
        }
        else
            @(Html.TextBoxFor(m => m.VialName, new { @class = "border-0", @readonly = "true", @style = "width:50px; margin-top:-8px" }))
    }
</div>

 

 

 

 

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Ed
Top achievements
Rank 1
Veteran
answered on 30 Jan 2020, 08:01 AM

Hi,

Nevermind. I figured it out. Need to show and hide things in js on the Edit event.

Thanks … Ed

 

Tags
Grid
Asked by
Ed
Top achievements
Rank 1
Veteran
Answers by
Ed
Top achievements
Rank 1
Veteran
Share this question
or