KendoUI Row绑定下拉菜单

Posted 心以不防

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了KendoUI Row绑定下拉菜单相关的知识,希望对你有一定的参考价值。

 $("#SalleGrid").kendoGrid({
        dataSource: {
            transport: {
                read: {
                    dateType: ‘application/json‘,
                    url: ‘/SalesTicket/Single/GG‘,
                    type: ‘POST‘,
                },

            },
            schema: {
                model: {
                    id: "ID",
                    fields: {
                        ID: { editable: false, nullable: true,},
                        Name: { defaultValue: { TouristTypeID: 4, TouristName: "Beverages" } }
                    }
                }
            },
            batch: true,
            pageSize: 15,
        },
        height: 200,
        selectable: "multiple",
        sortable: true,
        columns: [
             { field: "ID", title: "ID", hidden: true },
           { title: ‘门票代码‘, field: ‘TicketCode‘, editor: categoryDropDownEditor, template: "#=Name.TouristName#" },
         
        ],
        editable:true,
    });

 

function categoryDropDownEditor(container, options) {   
    $(‘<input required name="‘ + options.field + ‘"/>‘)
        .appendTo(container)
        .kendoDropDownList({
            autoBind: false,
            dataTextField: "TouristName",
            dataValueField: "TouristTypeID",
            dataSource: {
                transport: {
                    read: {
                        dataType: "json",
                        url: "/SalesTicket/Single/GetSelectList",
                    }
                }
            }
               
        }); }

Grid后台:

 [HandlerAjaxOnly]
        public ActionResult GG()
        {
            IQueryable<TouristTypeEntity> tourist = touristtypeApp.GetTouristTypeData();
            var result = from x in tourist
                         select
       new
       {
           ID = x.TouristTypeID,
           Name = new
           {
               TouristTypeID = x.TouristTypeID,
               TouristName = x.Name
           }
       };
            return Json(result);
        }

 

DropDownList:

public ActionResult GetSelectList()
        {
            IQueryable<TouristTypeEntity> tourist = touristtypeApp.GetTouristTypeData();
            var result = from x in tourist
                         select
       new
       {          
               TouristTypeID = x.TouristTypeID,
               TouristName = x.Name
     
       };
            return Json(result.ToList(),JsonRequestBehavior.AllowGet);
        }

 

以上是关于KendoUI Row绑定下拉菜单的主要内容,如果未能解决你的问题,请参考以下文章

KendoUI - 使用 MVVM 和远程数据时的级联下拉列表

如何修改 KendoUI DropDownList 项

如何将下拉菜单与切换组绑定

下拉菜单中怎么默认选中第一个呢,代码?(C#)

关于MVC视图下拉菜单绑定与取值的问题

如何在 Angular 2 的下拉菜单中使用两种方式绑定概念?