简体   繁体   English

如何向Kendo TreeList添加链接

[英]how to add a link to Kendo TreeList

I have the following code: 我有以下代码:

                var mdl = @Html.Raw(Json.Encode(Model.FacilityList));

                var ds = new kendo.data.TreeListDataSource({
                    data: mdl,
                    schema: {
                        model: {
                            id: "ClientOrganizationId",
                            fields: {
                                parentId: { field: "ParentOrganizationId",  nullable: true },
                                ClientOrganizationId: { field: "ClientOrganizationId", type: "number" },
                                Name: { field: "Name"},
                                Street: { field: "Street" },
                                City: { field: "City" },
                                State: { field: "State" },
                                ZipCode: { field: "Zipcode" }
                            },
                            expanded: true
                        }
                    }});

                $("#treelist").kendoTreeList({
                    dataSource: ds,
                    selectable: true,
                    columns: [
                        { field: "Name", title: "Organization Name"},
                        { field: "Contracted", title: "Contracted"},
                        { field: "ClientOrganizationId", title: "Id"},
                        { field: "Street", title: "Street"},
                        { field: "City", title: "City" },
                        { field: "State", title: "State" },
                        { field: "ZipCode", title: "ZipCode"}]});

How would I add another column that contains an actionlink to the "Home" controller's "Update" action passing the ClientOrganizationId as a parameter? 如何将包含Actionlink的另一列添加到“ Home”控制器的“ Update”操作中,并将ClientOrganizationId作为参数传递?

I want the Update action to be something like this 我希望更新动作是这样的

    public ActionResult Update(int Id)
    {
    }

You use a column template; 您使用列模板; basically something like: 基本上是这样的:

{ 
  field: "ClientOrganizationId", 
  title: "Id link", 
  template: "<a href='/Home/Update/#= ClientOrganizationId #'>" + 
            "link me to id: #= ClientOrganizationId # </a>"
},

Ie fill in whatever is needed to call the Update action while writing the id value with 即,在写入ID值的同时,填写调用Update操作所需的任何内容

#= ClientOrganizationId # #= ClientOrganizationId

(I don't remember the link semantics offhand, so the href part may be very wrong) (我不记得链接语义,所以href部分可能是非常错误的)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM