Kendo UI batch edit grid DropDownList does not show up

469 views Asked by At

I am using a kendo ui batch edit grid and I want to use a dropdown as a column of it. I read other topics about this subject and I did these steps:

1- I created a list of text/value and named it as DocumetTypesSelectList in a viewbag like this:

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

2- I Cast the viewbag as a list of SelectItems in my view like this:

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

3- I added a column to grid as follows:

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

but it does not open to select on of the items. on click you can change the value, and off click it shows the text using DocumetTypesSelectList . Thanks In Advance many thanks for your help

1

There are 1 answers

2
Waqar On BEST ANSWER

Please explain little bit more about

on click you can change the value, and off click it shows the text

It seems that here (System.Collections.IEnumerable)DocumetTypesSelectList you have missed your DocumetTypesSelectList object to pass on properly. You can do this in your controller by using ViewBag as ViewBag.DocumetTypesSelectListEx = DocumetTypesSelectList and use this ViewBag in your view as (System.Collections.IEnumerable)ViewBag.DocumetTypesSelectListEx

Second thing is, in your DocumetTypes you must have two fields one is for value and one is to display. It seems you have both as "Text" and "Value". Also check the demo here