Search code examples
asp.nettelerik

Kendo Editors not working in jQuery Steps?


I am using jQuery steps within a form. I have some model properties which I want to edit using Kendo Editors.

I a using following (partial) code, the rest is markup for the jQuery wizard:

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        <div class="form-group">
            @Html.LabelFor(model => model.Start, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Start, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Start, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.End, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.End, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.End, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">

            @(Html.Kendo().DropDownListFor(x => x.RecurrenceRule)
              .Name("recurrenceRule")
              .DataTextField("Text")
              .DataValueField("Value")
              .BindTo(new List<SelectListItem>
              {
                  new SelectListItem
                  {
                      Text = @"Nie",
                      Value = "Never"
                  },
                  new SelectListItem
                  {
                      Text = @"Täglich",
                      Value ="Daily"
                  },
                  new SelectListItem
                  {
                      Text = @"Monatlich",
                      Value ="monthly"
                  }
              }))
        </div>


    </div>





}

enter image description here

For some reason, the editors for Date properties are not properly displayed while the @(Html.Kendo().DropDownListFor( is working just fine. In another step (not documented here) @(Html.Kendo().MultiselectFor( does not work correctly either. What could cause this issue?

Update:

Positioning this code outside the markup for jQuery steps works fine. Here is my code for the wizard:

@using (Ajax.BeginForm("Wizard_Submit", "Wizard", new
{
    Area = ""
}, new AjaxOptions
{
    HttpMethod = "Post",
    InsertionMode = InsertionMode.Replace
}, new
{
    id = "wizardSumbit"
}))
{

    ////0
    <div id="wizard">
        <h3></h3>
        <section>
            <p></p>

            @(Html.Kendo().DropDownListFor(x => x.SlRateBaseTypes)
              .Name("slRateBaseTypes")
              .DataTextField("Text")
              .DataValueField("Value")
              .BindTo(new List<SelectListItem>
              {
                  new SelectListItem
                  {
                      Text = @"abc",
                      Value = ((int) SlRateBaseTypes.Course).ToString()
                  },
                  new SelectListItem
                  {
                      Text = @"cde",
                      Value = ((int) SlRateBaseTypes.Leisure).ToString()
                  }
              }))
        </section>

          @*//1*@
        <h3>Vorlage</h3>
        <section>
            <p>Wähle eine Vorlage aus</p>

            @(Html.Kendo().DropDownListFor(x => x.OfferingTemplateId)
              .Name("offeringTemplate")
              .DataTextField("Text")
              .DataValueField("Value")
              .Events(x => x.Change("onOfferingTemplateChange"))
              .DataSource(
                      source => source
                              .Read(read => read.Url(Url.Action("Wizard_GetOfferingTemplates", "Wizard")).Data("getSlRateBaseTypesSelection").Type(HttpVerbs.Post))
                              .ServerFiltering(true)
                  )
              .AutoBind(false))
            <div id="offeringTemplateDescription"></div>
        </section>


        @*//2*@
        <h3></h3>
        <section>
            <p></p>
            <label for="optional"></label>
            @(Html.Kendo().MultiSelectFor(x => x.SlRateBaseTypes)
            .Name("selectOfferingRateTypes")
            .Placeholder("")
             .AutoClose(false)
            .DataTextField("Text")
            .DataValueField("Value")
            .DataSource(
                      source => source
                              .Read(read => read.Url(Url.Action("Wizard_GetPossibleOfferingRates", "Wizard")).Data("getSlRateBaseTypesSelection").Type(HttpVerbs.Post))
                              .ServerFiltering(true)
                  )
            )



..
}

Developer options reveal following :

"Cannot read property 'inspectKendoWidget' of undefined" "TypeError: Cannot read property 'inspectKendoWidget' of undefined at :1:15"

Update 2:

this is the html code for the documented datepicker:

    <span class="k-widget k-datetimepicker k-header k-input" style="width: 100%;">
    <span class="k-picker-wrap k-state-default"><input data-val="true" data-val-date="The field Start must be a date." data-val-required="The Start field is required." id="Start" name="Start" type="text" value="01.01.0001 00:00" data-role="datetimepicker" class="k-input" role="combobox" aria-expanded="false" aria-disabled="false" style="width: 100%;" vk_15f93="subscribed">
    <span unselectable="on" class="k-select">
    <span class="k-link k-link-date" aria-label="Open the date view">
    <span unselectable="on" class="k-icon k-i-calendar" aria-controls="Start_dateview"><
    /span>
    </span>
    <span class="k-link k-link-time" aria-label="Open the time view">
    <span unselectable="on" class="k-icon k-i-clock" aria-controls="Start_timeview">
    </span>
    </span>
</span>
</span>
</span>

Solution

  • Just in case anybody cares:

    you'll have to remove some css styles in the jQuery steps css file -> change to:

    .tabcontrol ul > li
    {
        display: block;
        /*padding: 0;*/
    }
    

    Update: Also important: Actually the basic problem was solved by modifiying the jquery.steps.js file according to another post I found on the internet:

    --> comment this section

    //function render(wizard, options, state)
    //{
    //    // Create a content wrapper and copy HTML from the intial wizard structure
    //    var wrapperTemplate = "<{0} class=\"{1}\">{2}</{0}>",
    //        orientation = getValidEnumValue(stepsOrientation, options.stepsOrientation),
    //        verticalCssClass = (orientation === stepsOrientation.vertical) ? " vertical" : "",
    //        contentWrapper = $(wrapperTemplate.format(options.contentContainerTag, "content " + options.clearFixCssClass, wizard.html())),
    //        stepsWrapper = $(wrapperTemplate.format(options.stepsContainerTag, "steps " + options.clearFixCssClass, "<ul role=\"tablist\"></ul>")),
    //        stepTitles = contentWrapper.children(options.headerTag),
    //        stepContents = contentWrapper.children(options.bodyTag);
    
    //    // Transform the wizard wrapper and remove the inner HTML
    //    wizard.attr("role", "application").empty().append(stepsWrapper).append(contentWrapper)
    //        .addClass(options.cssClass + " " + options.clearFixCssClass + verticalCssClass);
    
    //    // Add WIA-ARIA support
    //    stepContents.each(function (index)
    //    {
    //        renderBody(wizard, state, $(this), index);
    //    });
    
    //    stepTitles.each(function (index)
    //    {
    //        renderTitle(wizard, options, state, $(this), index);
    //    });
    
    //    refreshStepNavigation(wizard, options, state);
    //    renderPagination(wizard, options, state);
    //    }
    

    -->replace with this

    function render(wizard, options, state) {
        // Create a content wrapper and copy HTML from the intial wizard structure
        var contentWrapperTemplate = "<{0} class=\"{1}\"></{0}>",
            stepsWrapperTemplate = "<{0} class=\"{1}\">{2}</{0}>",
            orientation = getValidEnumValue(stepsOrientation, options.stepsOrientation),
            verticalCssClass = (orientation === stepsOrientation.vertical) ? " vertical" : "",
            contentWrapper = $(contentWrapperTemplate.format(options.contentContainerTag, "content " + options.clearFixCssClass)),
            stepsWrapper = $(stepsWrapperTemplate.format(options.stepsContainerTag, "steps " + options.clearFixCssClass, "<ul role=\"tablist\"></ul>"));
    
        // Transform the wizard wrapper by wrapping the innerHTML in the content wrapper, then prepending the stepsWrapper
        wizard.attr("role", "application").wrapInner(contentWrapper).prepend(stepsWrapper)
            .addClass(options.cssClass + " " + options.clearFixCssClass + verticalCssClass);
    
        //Now that wizard is tansformed, select the the title and contents elements
        var populatedContent = wizard.find('.content'),
            stepTitles = populatedContent.children(options.headerTag),
            stepContents = populatedContent.children(options.bodyTag);