Hi,
I have a property stakeHolder he is an object type of Developer.
In my grid I want to add a product but the field stakeHolder is editable(false) and i put on it the name I want hard coded.
The problem is if I use stakeHolder.Name then sorting and filtering work good but when i trying to add row then an error occurred " StakeHolder is not defined"
and when I use stakeHolder then everything is working great except for sorting and filtering (as I know filtering/sorting don't work on object)
what can I do?
namespace TaskManagementUI.Models
{
public class Developer
{
public int? ID { get; set; }
[Required(ErrorMessage = "Please enter a name")]
[Display(Name = "Name")]
public string Name { get; set; }
}
@(Html.Kendo().Grid<TaskManagementUI.Models.ProductViewModel>()
.Name("GridProducts")
.Columns(columns =>
{
columns.Bound(c => c.ID).Hidden();
columns.Bound(c => c.Name).Title("Name").Width(200);
columns.Bound(c => c.CreateDate).Title("Creation date").Format("{0: MM/dd/yyyy}").Width(200);
columns.Bound(c=>c.StakeHolder.Name).Title("Creator").Width(200);
columns.Bound(c => c.Description).Title("Description").Width(250);
columns.Command(command => command.Custom("ADDPROJECT").Text("Add Project").Click("addProject")).Title("Add Project").Width(170).HtmlAttributes(new { id = "addProjectButton" });
columns.Command(command => { command.Edit().UpdateText("SAVE"); command.Destroy(); }).Width(250);
})
.Resizable(resize => resize.Columns(true))
.Filterable()
.ToolBar(toolbar =>
{
toolbar.Excel();
toolbar.Create().Text("Add New Product");
})
.Editable(editable => editable.Mode(GridEditMode.InLine).TemplateName(""))
.Excel(excel => excel
.AllPages(true)
.FileName("Products.xlsx")
.Filterable(true)
.ForceProxy(true)
.ProxyURL(Url.Action("FileExportSave", "Home")))
.Pageable(pager => pager
.Refresh(true)
.PageSizes(true)
.PageSizes(new int[] { 6, 15, 20 })
.ButtonCount(5))
.Sortable(sortable =>
{
sortable.SortMode(GridSortMode.MultipleColumn)
.Enabled(true);
})
.Scrollable()
.Events(e=>e.Edit("onProductEdit").Save("onProductSave").Cancel("onProductCancel").DataBound("onDataBoundSavedProducts"))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Events(events => events.Error("errorHandlerProduct"))
.Model(model =>
{
model.Id(item => item.ID);
model.Field(a => a.StakeHolder.Name).DefaultValue(new Developer {ID=52,Name="Uriel Ash"}).Editable(false);
model.Field(a => a.CreateDate).Editable(false);
})
.Read(read => read.Action("GetSavedProducts", "Product"))
.Update(update => update.Action("UpdateProduct", "Product"))
.Destroy(update => update.Action("DeleteProduct", "Product"))
.Create(update => update.Action("CreateProduct", "Product"))))