I have a Grid with Edit Pupup Custom Template and I need to transfer the data from the controller to the DropdownList. I need some help.
This is the part of my controler
_______________________
using OVFixedAssets.OVDataContext;
namespace OVFixedAssets.Controllers
{
public class FixedAssetsController : Controller
{
private OVFixedAssetsEntities db = new OVFixedAssetsEntities();
public JsonResult GetProjects([DataSourceRequest] DataSourceRequest request)
{
var oventities = new OVFixedAssetsEntities();
{
var projects = oventities.Projects.Select(project => new Project()
{
ProjectID = project.ProjectID,
ProjectName = project.ProjectName
});
return Json(projects, JsonRequestBehavior.AllowGet);
}
}
____________________________
Grid View
@(Html.Kendo().Grid<OVFixedAssets.OVDataContext.tblAssetsDetail>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(c => c.ProjectNo);
columns.Bound(c => c.AssetID);
columns.Bound(c => c.Item);
columns.Bound(c => c.Make);
columns.Bound(c => c.Model);
columns.Bound(c => c.SerialNumber);
columns.Bound(c => c.TagID);
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(175);
})
.HtmlAttributes(new {style = "height: 750px; Width:90%" })
.ToolBar(toolbar => {
toolbar.Create();
})
.ColumnMenu()
//.Editable(editable => editable.Mode(GridEditMode.PopUp))
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("FixedAssetDetails"))
.Resizable(resizable => resizable.Columns(true))
.Pageable( pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5)
)
.Navigatable()
.Filterable()
.Scrollable()
.Events(events => {
events.ColumnResize("onColumnResize");
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(25)
.Model(model => model.Id(p => p.ID))
.Read(read => read.Action("tblAssetsDetails_Read", "FixedAssets"))
.Create(create => create.Action("tblAssetsDetails_Create", "FixedAssets"))
.Update(update => update.Action("tblAssetsDetails_Update", "FixedAssets"))
.Destroy(destroy => destroy.Action("tblAssetsDetails_Destroy", "FixedAssets"))
)
)
<script>
function onColumnResize(e){
//Implement the event handler for ColumnResize
}
</script>
_______________________________
EditTemplate
The edit template in inside Share\EditorTemplates
@using OVFixedAssets.Controllers
@model OVFixedAssets.OVDataContext.tblAssetsDetail
@{
ViewBag.Title = "Fixed Asset Details";
}
<p class="ovtitle1">Asset Details</p>
@(Html.Kendo()
.TabStrip()
.Name("tabstrip")
.Animation(animation => animation.Open(effect => effect.Fade(FadeDirection.In)))
.Items(tabstrip =>
{
tabstrip.Add()
.Text("Details")
.Selected(true)
.Content(@<text>
<div class="weather">
<div class="form-group">
<h5>Project No.</h5>
@*@(Html.Kendo()
.TextBoxFor(model => model.ProjectNo)
.Name("ProjectNo")
.HtmlAttributes(new { placeholder = "Project No.", required = "required", validationmessage = "Project Name", })
)*@
@(Html.Kendo().DropDownList()
.Name("ProjectsDropDownList")
.DataTextField("ProjectName")
.DataValueField("ProjectID")
.DataSource(source => { source.Read(read => { read.Action("GetProjects", "FixedAssets"); }); })
)
</div>
<div class="form-group">
<h5>Product Description</h5>
@(Html.Kendo()
.TextBoxFor(model => model.Item)
.Name("Item")
.HtmlAttributes(new { placeholder = "Item Description", required = "required", validationmessage = "Enter Asset Description", style = "width:500px" ,})
)
</div>
<div class="form-group">
<h5>Serial No.</h5>
@(Html.Kendo()
.TextBoxFor(model => model.SerialNumber)
.Name("SerialNumber")
.HtmlAttributes(new { placeholder = "Serial No." })
)
</div>
<div class="form-group">
<h5>Tag ID:</h5>
@(Html.Kendo()
.TextBoxFor(model => model.TagID)
.Name("TagID")
.HtmlAttributes(new { placeholder = "Tag ID." })
)
</div>
<div class="form-group">
<h5>Model No.</h5>
@(Html.Kendo()
.TextBoxFor(model => model.Model)
.Name("Model")
.HtmlAttributes(new { placeholder = "Model No." })
)
<div class="form-group">
<h5>Brand.</h5>
@(Html.Kendo()
.TextBoxFor(model => model.Make)
.Name("Make")
.HtmlAttributes(new { placeholder = "Brand Name." })
)
</div>
</div>
</div>
</text>);
tabstrip.Add()
.Text("Comments")
.Content(@<text>
<div class="weather">
<h5>Comments.</h5>
@(Html.Kendo()
.TextBoxFor(model => model.Comments)
.Name("Comments")
.HtmlAttributes(new { placeholder = "Comments" })
)
</div>
</text>);
tabstrip.Add()
.Text("Garantias")
.Content(@<text>
<div class="weather">
</div>
</text>);
tabstrip.Add()
.Text("Registro de Visitas")
.Content(@<text>
<div class="weather">
</div>
</text>);
})
)
</div>
-------------
I include some of the files.
Thanks...