Kendo UI将控制值传递到数据源

发布于 2025-02-03 07:34:26 字数 700 浏览 3 评论 0原文

嗨,我有一个相当简单的多选择下拉列表,其中以下数据源

@(Html.Kendo().MultiSelectFor(model => model.UserId)
    .Name("UserId")
    .HtmlAttributes(new { style = "width:100%;" })
    .MinLength(2)
    .Filter(FilterType.Contains)
    .Placeholder("Select User...")
    .AutoBind(false)
    .Animation(false)
    .MaxSelectedItems(1)
    .DataSource(source =>
    {
        source.Read(read =>
        {
            read.Action("GetUsers", "CommonJsonActions");
        });
    })
    .DataValueField("UserId")
    .DataTextField("DisplayName")
    .BindTo(Model.Users)
    .Value(Model.Users)

我想知道是否有一种方法可以将另一个下拉列表的选定值传递给多选择的dropdown(例如id formType)?还是我必须将代码移至.js文件以将jQ​​uery用于此目的?

Hi I have a fairly simple MultiSelect dropdown with the following Datasource

@(Html.Kendo().MultiSelectFor(model => model.UserId)
    .Name("UserId")
    .HtmlAttributes(new { style = "width:100%;" })
    .MinLength(2)
    .Filter(FilterType.Contains)
    .Placeholder("Select User...")
    .AutoBind(false)
    .Animation(false)
    .MaxSelectedItems(1)
    .DataSource(source =>
    {
        source.Read(read =>
        {
            read.Action("GetUsers", "CommonJsonActions");
        });
    })
    .DataValueField("UserId")
    .DataTextField("DisplayName")
    .BindTo(Model.Users)
    .Value(Model.Users)

I'm wondering if there's a way I can pass the selected value of another dropdown, say id formType, to the MultiSelect? Or do I must move the code to .js file to utilize jquery for this purpose?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

踏月而来 2025-02-10 07:34:26

要将其他参数传递给动作,使用数据方法并提供JavaScript函数的名称,该函数将返回带有其他数据的JavaScript对象:

.DataSource(source =>
{
    source.Read(read =>
    {
        read.Action("GetUsers", "CommonJsonActions").Data("additionalData");
    });
})

<script>
   function additonalData(){
      return {
            formType: $("#formType").val(),
        };
  }
</script>

这是假设另一个下拉列表具有ID“ FormType”。操作方法应期望一个名为“ FormType”的附加参数。

To pass additional parameters to the action, use the Data method and provide the name of a JavaScript function which will return a JavaScript object with the additional data:

.DataSource(source =>
{
    source.Read(read =>
    {
        read.Action("GetUsers", "CommonJsonActions").Data("additionalData");
    });
})

<script>
   function additonalData(){
      return {
            formType: $("#formType").val(),
        };
  }
</script>

This is assuming the other DropDownList has an id "formType". The action method should expect an additional parameter named "formType".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文