更改Kendo UI上传小部件的文本

时间:2022-03-06 03:56:32

I would like to change the default text of Select to something more appropriate for the context. I'm using the Kendo Fluent API built on the HtmlHelper class and I didn't find a way to change the text neither in the basic functions nor in the localization.

我想将Select的默认文本更改为更适合上下文的内容。我正在使用基于HtmlHelper类构建的Kendo Fluent API,但我没有找到在基本函数和本地化中都不更改文本的方法。

My code is pretty simple and looks like this:

我的代码很简单,看起来像这样:

@(Html.Kendo().Upload()
      .Name("FilesToUpload")
)

There is a suggestion in this thread about a jQuery function to change the text, which works perfectly if I use the javascript API of the Upload widget but doesn't work when I create the widget via Html.Kendo().Upload.

在这个帖子中有一个关于改变文本的jQuery函数的建议,如果我使用上传小部件的javascript API但是当我通过Html.Kendo()创建小部件时不起作用,这种方法很有效。上传。

And even better with the javascript API there is a:

使用javascript API更好的是:

localization: {
    select: 'any text'
}

Settings you can use, but this doesn't help me either.

您可以使用的设置,但这对我也没有帮助。

If anyone has faced this problem before and tackled it I would really appreciate his help.

如果有人在遇到这个问题并解决之前我会非常感谢他的帮助。

3 个解决方案

#1


14  

I have just received an answer on the kendo forums in this thread. And the solution is pretty easy, but the feature was just a little hidden in the fluent interface:

我刚刚在这个帖子的kendo论坛上收到了答案。解决方案非常简单,但该功能只是隐藏在流畅的界面中:

@(Html.Kendo().Upload()
      .Name("FilesToUpload")
      .Messages( m => m.Select("Select unit bulk upload file"))
)

#2


1  

For AngularJS usages this is an example of using the localization, note the k-localization attribute:

对于AngularJS用法,这是使用本地化的一个示例,请注意k-localization属性:

<input name="Images" type="file" kendo-upload
        k-multiple="true"
        k-upload="inventoryProductDetail.uploadImage"
        k-success="inventoryProductDetail.uploadedImage"
        k-async="{ saveUrl: '/API/UploadFile/.json', autoUpload: true }"
        k-localization="{ select: 'SELECT ME!' }" />

#3


-1  

Unfortunatly you do have to follow the suggestions on that post. Here is how to do it in your situation.

不幸的是,你必须遵循该帖子上的建议。以下是在您的情况下如何做到这一点。

@(Html.Kendo().Upload()
      .Name("FilesToUpload")
)
<script type="text/javascript">
    $(document).ready(function () {
        $("#FilesToUpload").closest(".k-upload").find("span").text("my text");
    });
</script>

I try not to think that the Kendo controls are going to get me to 100%, because then I would be disappointed. Instead assume they will get you 90% of where you want to go quickly. Then use jQuery and some detective work to perfect.

我尽量不要认为剑道控制会让我达到100%,因为那时我会感到失望。相反,假设他们会在你想要快速前进的地方获得90%。然后使用jQuery和一些侦探工作来完善。

#1


14  

I have just received an answer on the kendo forums in this thread. And the solution is pretty easy, but the feature was just a little hidden in the fluent interface:

我刚刚在这个帖子的kendo论坛上收到了答案。解决方案非常简单,但该功能只是隐藏在流畅的界面中:

@(Html.Kendo().Upload()
      .Name("FilesToUpload")
      .Messages( m => m.Select("Select unit bulk upload file"))
)

#2


1  

For AngularJS usages this is an example of using the localization, note the k-localization attribute:

对于AngularJS用法,这是使用本地化的一个示例,请注意k-localization属性:

<input name="Images" type="file" kendo-upload
        k-multiple="true"
        k-upload="inventoryProductDetail.uploadImage"
        k-success="inventoryProductDetail.uploadedImage"
        k-async="{ saveUrl: '/API/UploadFile/.json', autoUpload: true }"
        k-localization="{ select: 'SELECT ME!' }" />

#3


-1  

Unfortunatly you do have to follow the suggestions on that post. Here is how to do it in your situation.

不幸的是,你必须遵循该帖子上的建议。以下是在您的情况下如何做到这一点。

@(Html.Kendo().Upload()
      .Name("FilesToUpload")
)
<script type="text/javascript">
    $(document).ready(function () {
        $("#FilesToUpload").closest(".k-upload").find("span").text("my text");
    });
</script>

I try not to think that the Kendo controls are going to get me to 100%, because then I would be disappointed. Instead assume they will get you 90% of where you want to go quickly. Then use jQuery and some detective work to perfect.

我尽量不要认为剑道控制会让我达到100%,因为那时我会感到失望。相反,假设他们会在你想要快速前进的地方获得90%。然后使用jQuery和一些侦探工作来完善。