首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在.NET内核的x-kendo-template中使用KendoDatePicker

如何在.NET内核的x-kendo-template中使用KendoDatePicker
EN

Stack Overflow用户
提问于 2019-05-24 01:50:38
回答 1查看 135关注 0票数 0

当我想要在我的Kendo网格中添加/编辑一行时,我有一个弹出式编辑器模板,它绑定到模型的属性。问题是我无法让Kendo小部件(例如datepicker或dropdownlist)在kendo-template中生成(主要是想使用taghelper)。我也不能在$(document).ready()上使用jQuery将输入转换成kendo小部件。我该怎么做呢?

我的网格:

代码语言:javascript
复制
<kendo-grid name="accountsGrid" height="500" on-detail-init="onDetailInit">
<datasource type="DataSourceTagHelperType.Ajax" page-size="10">
    <transport>
        <read url="?handler=Accounts&id=@Model.Id" data="getAntiForgeryKeyValue" type="POST" />
        <create url="?handler=CreateAccount&id=@Model.Id" data="getAntiForgeryKeyValue" type="POST" />
        <update url="?handler=EditAccount&id=@Model.Id" data="getAntiForgeryKeyValue" type="POST" />
    </transport>
    <schema>
        <model id="AccountId">
            <fields>
                <field name="LastUpdateDate" type="Date"></field>
            </fields>
        </model>
    </schema>
</datasource>
<columns>
    <column field="Id" hidden="true" />
    <column field="AccountName"
            title="Account Name"
            header-html-attributes='HeaderHtmlAttribute(title:"Account Name")' />
    <column field="LastUpdateDate"
            title="Last Updated"
            format="{0:MMMM dd, yyyy}"
            header-html-attributes='HeaderHtmlAttribute(title:"Last Updated")' />
    <column title="Actions"
            header-html-attributes='HeaderHtmlAttribute(title:"Actions")'
            html-attributes='new Dictionary<string, object> {["class"] = "center-cell" }'>
        <commands>
            <column-command name="edit" />
        </commands>
    </column>
</columns>
<toolbar>
    <toolbar-button name="create" template="getTelerikButton('Add')" />
</toolbar>
<editable mode="popup" template-id="accountEditorTemplate" />
<pageable button-count="5" refresh="true" page-sizes="new int[] { 5, 10, 20 }">
</pageable>
<scrollable enabled="true" />

我的编辑器模板:

代码语言:javascript
复制
<script id="accountEditorTemplate" type="text/x-kendo-template">
<div class="row editor-padding">
    @*Account Details*@
    <div class="col-md-6 col-xs-12">
        <h5 class="editorTemplateHeader">Account Details</h5>
        <div class="k-edit-label">
            <label for="AccountName">Account Name</label>
        </div>
        <div class="k-edit-field">
            <input required type="text" class="k-input k-textbox" name="AccountName" validationmessage="Account Name is required" maxlength="8" />
        </div>
        <div class="k-edit-label">
            <label for="Description">Description</label>
        </div>
        <div class="k-edit-field">
            <input type="text" class="k-input k-textbox" name="Description" maxlength="100" />
        </div>
        <div class="k-edit-label">
            <label for="ExpirationDate">Expiration Date</label>
        </div>
        <div class="k-edit-field">
            @*I would like to do this, but nothing appears*@
            <kendo-datepicker name="ExpirationDate"></kendo-datepicker>
        </div>
    </div>
</div>

EN

回答 1

Stack Overflow用户

发布于 2019-05-24 23:05:30

我解决了这个问题。它涉及到使用data-语法。以下是解决方案:

代码语言:javascript
复制
<div class="k-edit-field">
    <input required type="text"
        name="ExpirationDate"
        data-type="date"
        data-bind="value:ExpirationDate"
        data-role="datepicker" 
        validationmessage="Expiration Date is required" />
</div>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56280545

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档