Kendo UI Fügen Sie Dropdownlist in Grid (MVC) hinzu

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Kendo UI Fügen Sie Dropdownlist in Grid (MVC) hinzu

by Anonymous » 16 Mar 2025, 13:04

Ich bin bindend an eine Gitterklasse (userId, FirstName, LastName, Choice).

Code: Select all

@(Html.Kendo().DropDownList()
.Name("Test")
.DataTextField("Text")
.DataValueField("Value")
.Events(e => e.Change("change"))
.BindTo(new List()
{
new SelectListItem()
{
Text = "Option1",
Value = "1"
},
new SelectListItem()
{
Text = "Option2",
Value = "2"
}
}))

function change() {
var value = $("#Choice").val();
}

< /code>
....
columns.Bound(p=> p.FirsName);
columns.Bound(p => p.LastName);
//How to Bind Choice???
< /code>
Ich brauche auch einen Text ("option1" oder "option2") im Backend -Code.
irgendwelche Lösungen? columns.Bound(p => p.Choice).ClientTemplate("#=Choice#");
< /code>
Controller: < /p>
public ActionResult Index()
{
PopulateCategories();
return View();
}

< /code>
....
 private void PopulateCategories()
{
var dataContext = new TestDB();
var categories = dataContext.Peoples
.Select(c => new People()
{
ChoiceID = c.ChoiceID,
Choice = c.Choice
})
.OrderBy(e => e.Choice);
ViewData["categories"] = categories;
ViewData["defaultCategory"] = categories.First();
}

Aber das funktioniert nicht ...

Top