【问题标题】:Appropriate js kendo template for website适合网站的js剑道模板
【发布时间】:2017-12-30 08:28:33
【问题描述】:

我在我的网站中只使用剑道模板并使用这个 js: kendo.cdn.telerik.com/2015.2.805/js/kendo.all.min.js

但是这个文件非常非常大(2.102 KB)。我想要一个合适的剑道 js 文件来解决这个问题,但我不知道:

我的代码是:

<script>
    function FillSpecificationAttr(attrId) {
        var template = kendo.template($("#template").html());
        var ID = attrId;
        var dataSource = new kendo.data.DataSource({
            type: "json",
            transport: {
                read: {
                    url: "../AjaxFunctionPages.asmx/ProductSpecAttrList",
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    data: {
                        ID: ID
                    }
                },
                destroy: {
                    url: "../../AjaxFunctionsAdminPages.asmx/TierPriceDelete",
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    data: {
                        ID: ID
                    }
                },
                parameterMap: function (data, operation) {
                    if (operation != "read") {
                        // web service method parameters need to be send as JSON. The Create, Update and Destroy methods have a "products" parameter.
                        return JSON.stringify({ ID: data.Id })
                    }
                    else if (operation == "destroy") {
                    }
                    else {
                        // web services need default values for every parameter
                        data = $.extend({ sort: null, filter: null }, data);
                        return JSON.stringify(data);
                    }
                }
            },
            schema: {
                data: "d.Data"
            },
            requestStart: function () {
                kendo.ui.progress($("#tblConfigProduct"), true);
            },
            requestEnd: function () {
                kendo.ui.progress($("#tblConfigProduct"), false);
            },
            change: function () {
                $("#tblConfigProduct").html(kendo.render(template, this.view()));
            }
        });
        dataSource.read();
    };
</script>

【问题讨论】:

  • 发生了什么?需要帮助吗?
  • @DontVoteMeDown 嗨。此 js 不适用于模板和“kendo.data.DataSource”。获取数据和填充数据源时出错。
  • 好吧,在您的问题中,您只询问了模板。我猜你必须添加 kendo.data.js。

标签: javascript jquery asp.net kendo-ui


【解决方案1】:

我认为模板是在kendo.core.min.js 文件中定义的,在版本2017.2.504 中只有54KB 的大小。您仍然需要 jQuery 库作为在文档中添加的必需依赖项。

Demo

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-06
    • 2023-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多