Hi, as i'm new to these forums, i hope you will not be to hard on me if the solutions is obvious :-)
Let's say i have setup this grid with Products including a foreign key dropdownlist to ProductTypes. Some of these ProductTypes are no longer in use (marked boolean property 'IsValid')
The requirement is that all Products with ProductType are shown independent of the 'IsValid property'. So far so good.
Now the point where i need some help: when a record is added, i would like the ProductType dropdown to only list ProductTypes that are marked as valid. And to make it even more difficult: When a row is in edit mode, i would like the dropdown to only show the valid ProductTypes AND the current ProductType even if that is invalid.
Let's say i have setup this grid with Products including a foreign key dropdownlist to ProductTypes. Some of these ProductTypes are no longer in use (marked boolean property 'IsValid')
The requirement is that all Products with ProductType are shown independent of the 'IsValid property'. So far so good.
Now the point where i need some help: when a record is added, i would like the ProductType dropdown to only list ProductTypes that are marked as valid. And to make it even more difficult: When a row is in edit mode, i would like the dropdown to only show the valid ProductTypes AND the current ProductType even if that is invalid.
public
class
ProductController : Controller
{
private
DBEntities db =
new
DBEntities ();
public
ActionResult Index()
{
ViewData[
"ProductTypes"
] = db.ProductTypes.Select(b =>
new
{ Id = b.idProductType, Name = b.ShortName });
return
View();
}
@(Html.Kendo().Grid<Data.EF.Models.Product>()
.Name(
"grid"
)
.Columns(columns =>
{
columns.Bound(c => c.Code);
columns.Bound(c => c.Color);
columns.ForeignKey(c => c.idProductType,
(System.Collections.IEnumerable)ViewData[
"ProductType"
],
"Id"
,
"Name"
).Title(
"Type"
);
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(180);
})
.ToolBar(toolbar => {
toolbar.Create();
toolbar.Excel();
})
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Sortable(sortable => {
sortable.SortMode(GridSortMode.MultipleColumn);
})
.Filterable()
.Scrollable(scrollable => scrollable.Enabled(
false
))
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(p => p.idProduct))
.Read(read => read.Action(
"KProduct_Read"
,
"Product"
))
.Create(create => create.Action(
"Product_Create"
,
"Product"
))
.Update(update => update.Action(
"Product_Update"
,
"Product"
))
.Destroy(destroy => destroy.Action(
"Product_Destroy"
,
"Product"
))
)
)