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') {
debugger;
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.
THANKS!
Chris