This is a migrated thread and some comments may be shown as answers.

Grid Edit Template -> Sending back ALL listbox items

1 Answer 150 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Christopher asked on 28 Aug 2017, 03:55 PM

Hi there

I have a grid bound to a data source. It is an ajax grid. I am trying to use a Popup editor template for adding new items. In the template, I have a simple

regular HTML listbox.

@Html.ListBoxFor(x => x.DropdownListOptions, new SelectList(Model.DropdownListOptions), new {id = "dropdownlistBox", @class = "form-control", multiple= "multiple" })</div>

The postback returns all the data in the listbox if they are selected. If none are selected, the model binding field is null. (This is normal behaviour)


Now usually in ASP.NET MVC you just write a simple Jquery on postback to select all the listbox items before postback, like so:

$("#dropdownlistBox option").attr("selected", "selected");

This works just fine without using Telerik controls. However when I use this via Telerik Grid -> Popup -> Edit template. Even tho I visually see ALL fields being selected. The model field is still null.

I have confirmed that the values are not posted back from the browser using devtools.

I have even gone so far as to use jquery to fire off a grid event on .RequestStart('selectAllInListBox') like so:


var selectAllInListBox = function(e) {
        if (e.type === 'create') {
            var ddl = $('#dropdownlistBox option');
            if (ddl.length > 0)
                var lastEl = e.sender._data[e.sender._data.length - 1];
                var optionsArray = ['test', 'test2', 'test3'];
                lastEl.DropdownListOptions = optionsArray;


Forcing the actual grid data source to update the values. By the time it gets back to my controller, it is still null.


Is there an easy way to do this? I have exhausted all options.






1 Answer, 1 is accepted

Sort by
Telerik team
answered on 30 Aug 2017, 07:36 AM
Hello Chris,

Thank you for the provided details.

I made an example with a Popup editing, ListBoxFor and it is working as expected on my end.

I attached the example for reference. Please have in mind that it will only send one value(from the ListBox) as the field in the model is a string.

Also, when there are multiple values we can recommend using the MultiSelect widget as editor for the Grid:

Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question