kendo ui multiselect remove delete action

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 06:37:05

问题


How can i restrict users from deleting the already saved items in the Multi select widget. Users should not be able to delete existing values but can add or remove the new values.

The solution i tried was on databound remove the delete icon like below. It gets deleted but comes back after the call executes the databound method.

Any ideas?

onDataBound: function (e) {
        e.preventDefault();
        $(e.sender.tagList).find("li span.k-delete").remove();
    }

This is the code in the view which calls the above js function on databound

 @(Html.Kendo().MultiSelectFor(x => x.Documents)
                      .DataTextField("Description")
                      .DataValueField("Code")
                      .Placeholder("Select Attachment...")
                      .AutoBind(false)
                      .DataSource(source => source.Read(read => read.Action("GetCustomerDocuments", "CustomerRequest")).ServerFiltering(true))
                      .HtmlAttributes(new {style = "width:400px;"}) 
                      .Events(e => e.DataBound("onDataBound"))                            
                      )  

回答1:


Have your tried applying the same method on the change event as on the databound event?

Razor:

.Events(e => e.Change("onChange"))

Javascript:

onChange: function (e) {
    e.preventDefault();
    $(e.sender.tagList).find("li span.k-delete").remove();
}


来源:https://stackoverflow.com/questions/26507752/kendo-ui-multiselect-remove-delete-action

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!