css - 如何在默认的 Kendo 样式上加载不同的 Kendo UI Slider

标签 css kendo-ui telerik slider

我正在为我的 ASP.net MVC 应用程序中的 Kendo 控件使用下面给出的 CSS:

@Styles.Render("~/Content/Telerik/styles/kendo.common.css")
@Styles.Render("~/Content/Telerik/styles/kendo.default.css")

但是我不希望在 Kendo Slider 控件上应用默认样式,并希望加载不同的主题,比如可以在 this 中看到的“Silver”主题演示

我怎样才能实现它?

最佳答案

您可以在下面的链接中找到其他样式的 css。

https://github.com/telerik/kendo-ui-core/tree/master/styles/web

在您的元素中下载并导入 css。

在此之后,使用下面的函数你可以实现改变主题。

$(function() {
 changekendoTheme("Silver");
});

 function changekendoTheme(skinName, animate) {
        var doc = document,
            kendoLinks = $("link[href*='kendo.']", doc.getElementsByTagName("head")[0]),
            commonLink = kendoLinks.filter("[href*='kendo.common']"),
            skinLink = kendoLinks.filter(":not([href*='kendo.common'])"),
            href = location.href,
            skinRegex = /kendo\.\w+(\.min)?\.css/i,
            extension = skinLink.attr("rel") === "stylesheet" ? ".css" : ".less",
            url = commonLink.attr("href").replace(skinRegex, "kendo." + skinName + "$1" + extension),

            url2 = commonLink.attr("href").replace(skinRegex, "kendo.dataviz." + skinName + "$1" + extension);

        exampleElement = $("#example");

        function preloadStylesheet(file, callback) {
            var element = $("<link rel='stylesheet' media='print' href='" + file + "'").appendTo("head");
            setTimeout(function () {
                callback();
                element.remove();
            }, 100);
        }

        function replaceTheme() {
            var oldSkinName = $(doc).data("kendoSkin"),newLink;
            var newLink1 = doc.createElement('link');
            newLink1.setAttribute("rel", "stylesheet");
            newLink1.setAttribute("href", url);

            var newLink2 = doc.createElement('link');
            newLink2.setAttribute("rel", "stylesheet");
            newLink2.setAttribute("href", url2);

            var head = document.head;

            head.insertBefore(newLink2, skinLink[0]);
            head.insertBefore(newLink1, skinLink[0]);

            skinLink.remove();

            $(doc.documentElement).removeClass("k-" + oldSkinName).addClass("k-" + skinName);
        }

        if (animate) {
            preloadStylesheet(url, replaceTheme);
        } else {
            replaceTheme();
        }

关于css - 如何在默认的 Kendo 样式上加载不同的 Kendo UI Slider,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41460512/

相关文章:

html - 文本未换行在 IE7 内的宽度的 div 中

javascript - Bootstrap 3 : how to make head of dropdown link clickable in navbar

angularjs - Kendo UI 指令要求 jQuery 在 AngularJS 之前可用。请在文档中的 angular 之前包含 jquery

kendo-ui - iframe 模式下的剑道窗口 : the URL is not being requested from the server

asp.net - RadAjaxManager 不会更新 radgrid

xamarin - “Resource”不包含“Animation”的定义

html - 如何去除提交按钮上的灰色边框?

html - 如何覆盖 Bootstrap 3 导航栏边距类

kendo-ui - 使用 Entity Framework 的具有 bool 类型值的 Kendo ui mvc dropdownlistfor

javascript - 处理剑道调度程序中的销毁事件