簡體   English   中英

Kendo UI批處理編輯網格DropDownList不顯示

[英]Kendo UI batch edit grid DropDownList does not show up

我正在使用kendo ui批處理編輯網格,並且想使用下拉列表作為它的一列。 我閱讀了有關此主題的其他主題,並執行了以下步驟:

1-我創建了一個文本/值列表,並在這樣的視圖包中將其命名為DocumetTypesSelectList:

            ViewBag.DocumetTypesSelectList = DocumentTypesBll.GetDocumentTypes().ToList().Select(item => new SelectListItem
        {
            Value = item.DocumentTypeId.ToString(),
            Text = item.Title
        }).ToList();

2-我在視圖中將viewbag轉換為SelectItem的列表,如下所示:

var DocumetTypesSelectList = ViewBag.DocumetTypesSelectList as List<SelectListItem> ?? new List<SelectListItem>();

3-我在網格中添加了一個列,如下所示:

columns.ForeignKey(p => p.DocumentTypeId, (System.Collections.IEnumerable)DocumetTypesSelectList, dataFieldText: "Text", dataFieldValue: "Value")

但無法打開以選擇其中的一項。 單擊時,您可以更改該值,然后單擊,它會使用DocumetTypesSelectList顯示文本。 在此先感謝您的幫助

請多說明一些

單擊時,您可以更改值,單擊時,它會顯示文本

似乎在這里(System.Collections.IEnumerable)DocumetTypesSelectList您錯過了您的DocumetTypesSelectList對象以正確傳遞。 您可以通過將ViewBag用作ViewBag.DocumetTypesSelectListEx = DocumetTypesSelectList並在您的視圖中將此ViewBag用作(System.Collections.IEnumerable)ViewBag.DocumetTypesSelectListEx來在控制器中執行此(System.Collections.IEnumerable)ViewBag.DocumetTypesSelectListEx

第二件事是,在您的DocumetTypes中,您必須有兩個字段,一個是值,另一個是要顯示。 看來您同時具有“文本”和“值”兩個字。 也可以在這里查看演示

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM