I developed a Kendo MVC Grid which displays a pop-up for updates. Popup Edit screen is a Custom template with a dropdown list that calls the controller to populate the . In this case, I am populating the prefixes. The is populated fine, but when I click on a row on the grid to edit an item, I need to pre-select the value in the drop-down. let's say if a particular row has a value of "Mr." as a prefix, I need it to be pre-selected in the popup .
If the use of a @Html.EditorFor(model => model.Prefix), it perfectly populates the editor fine. This doesn't work for Dropdown.
The editor template is called MemberEdit and the code in it is as below:
01.@model Aamva.Api.Common.WebSite.Models.WebUser02. <div class="col-lg-2">03. @Html.LabelFor(model => model.Prefix)04. @*@Html.EditorFor(model => model.Prefix)*@05. @(Html.Kendo().DropDownList()06. .Name("ddlPrefix")07. .DataTextField("Prefix")08. .DataValueField("PrefixKey")09. .DataSource(source =>10. {11. source.Read(read =>12. {13. read.Action("ListCustomerPrefix", "Home"); //.Data("additionalPrefixData");14. })15. .ServerFiltering(true);16. })17. // .Text(Model.Prefix)18. .Value(Model.PrefixKey)19. .AutoBind(false)20. .HtmlAttributes(new { style = "width: 100%" })21. )22. </div>23. <div class="col-lg-2">24. @Html.LabelFor(model => model.FirstName)25. @Html.EditorFor(model => model.FirstName)26. @Html.ValidationMessageFor(model => model.FirstName)27. </div>
The Grid code is as shown below:
01.@(Html.Kendo().Grid<Aamva.Api.Common.WebSite.Models.WebUser>()02. .Name("membersGrid")03. .Columns(columns =>04. {05. columns.Command(command => { command.Edit(); command.Destroy().Text("EZ Del"); }).Width("15%");06. columns.Bound(p => p.CST_KEY).Visible(false);07. columns.Bound(p => p.FullName).Width("20%").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains").SuggestionOperator(FilterType.Contains)));08. columns.Bound(p => p.Role).Width("25%").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains").SuggestionOperator(FilterType.Contains)));09. columns.Bound(p => p.Title).Width("20%").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains").SuggestionOperator(FilterType.Contains)));10. columns.Bound(p => p.EmailAddress).Width("20%").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains").SuggestionOperator(FilterType.Contains)));11. columns.Bound(p => p.Prefix).Visible(false);12. columns.Bound(p => p.Suffix).Visible(false);13. columns.Bound(p => p.RoleKey).Visible(false);14. columns.Bound(p => p.OrganizationMemberKey).Visible(false);15. }).Filterable(filterable => filterable17. .Extra(false)18. .Operators(ops => ops19. .ForString(str => str.Clear()20. .Contains("Contains")21. .StartsWith("Starts With")22. .IsEqualTo("Is Equal To")23. .IsNotEqualTo("Is Not Equal To")24. )))25. .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("MemberEdit").Window(w => w.Title("Edit Employee").Width(1100)))26. .Pageable(pager => pager.AlwaysVisible(false).PageSizes(new List<object> { 5, 10, 15, 20 }))27. .Sortable()28. .Filterable(ftb => ftb.Mode(GridFilterMode.Row))29. .HtmlAttributes(new { style = "width:100%;" })30. .DataSource(dataSource => dataSource31. .Ajax()32. .PageSize(10)33. .Events(events => events.Error("error_handler"))34. .Model(model => model.Id(p => p.CST_KEY))35. .Read(read => read.Action("ListMembers", "Home"))36. .Update(update => update.Action("EditingPopup_Update", "Home"))37. .Model(model =>38. {39. 40. model.Field(m => m.Title);41. model.Field(m => m.Prefix);42. model.Field(m => m.PrefixKey);43. model.Field(m => m.Suffix);44. model.Field(m => m.FirstName);45. model.Field(m => m.MiddleName);46. model.Field(m => m.LastName);47. model.Field(m => m.OrganizationKey);48. model.Field(m => m.FullName);49. model.Field(m => m.CustomerId);50. model.Field(m => m.OrganizationMemberKey);51. model.Field(m => m.EmailAddress);52. model.Field(m => m.CST_KEY);53. model.Field(m => m.Role);54. model.Field(m => m.RoleKey);55. model.Field(m => m.RoleList).DefaultValue(new List<Aamva.Api.Common.WebSite.Models.WebUserRole>());56. }57. )58. )59.)The Model is as below:
01.public class WebUser02.{03. public string CST_KEY { get; set; }04. public string EmailAddress { get; set; }05. public string Prefix { get; set; }06. public string PrefixKey { get; set; }07. public string Suffix { get; set; }08. public string Title { get; set; }09. public string FirstName { get; set; }10. public string MiddleName { get; set; }11. public string LastName { get; set; }12. public string OrganizationKey { get; set; }13. public string Role { get; set; }14. public string RoleKey { get; set; }15. public List<WebUserRole> RoleList { get; set; }16.}17. public class WebUserPrefix20.{21. public string PrefixKey { get; set; }22. public string Prefix { get; set; }23.}

i have downloaded and installed latest version of kendo UI for mvc into existing project. since then the datetimepicker doesn't stay open,can anyone help me with this.
thanks

Hi,
I tried to set the grid height in percents and it's doesn't effect?
how can I do it? I want it to looks good in pc and laptop and I don't want to have 2 vertical scrollbar (one for the window and one for the grid)/ i want only for the grid.
Thanks

Hi,
I have a chart in Excel i'd like to replicate, i've attached an image of it (Chart1). I've currently gotten this far (Chart2).
Here's the code:
@(Html.Kendo().Chart<UtilisationOverall>() .Name("chart2") .Title("RDO") .Legend(legend => legend .Position(ChartLegendPosition.Top) ) .DataSource(ds => ds .Read(read => read.Action("UserUtilisationListRdoAjax", "Kendo", new { returnType = AjaxReturnType.Json })) .Group(group => { group.Add(model => model.FullName); }) ) .Series(series => { series.Column(model => model.TimesheetHours, categoryExpression: model => model.FullName) .Aggregate(ChartSeriesAggregate.Sum) .Stack(ChartStackType.Normal) .Name("#= group.value #"); }) .SeriesColors(Colours.Blue, Colours.Orange, Colours.Grey, Colours.Yellow, Colours.LightBlue, Colours.Green) .CategoryAxis(axis => axis .Labels(l => l.Rotation(90)) .MajorGridLines(lines => lines.Visible(false)) ) .ValueAxis(axis => axis .Numeric() .Line(line => line.Visible(false)) ) .Tooltip(tooltip => tooltip .Visible(true) .Template("#= series.name #: #= kendo.format('{0:N0}', value) #") ))
2 Issues:
My Class:
public class UtilisationOverall{ /// <summary> /// Persons Full Name /// </summary> public string FullName { get; set; } /// <summary> /// Timesheet Work Date Month Year /// </summary> public DateTime TimesheetWorkDateMonthYear { get; set; } /// <summary> /// Timesheet Overhead /// </summary> public string TimesheetOverhead { get; set; } /// <summary> /// Timesheet Hours /// </summary> public double TimesheetHours { get; set; }}
Hi,
I have a Grid where i group by the Year and Month from a DateTime (see attached Image - Table1), but without defining the columns and using the Title they display like so (see Table2 image):
How can i make them display properly without showing the Columns or even adding them?
columns.Bound(o => o.TimesheetWorkDateMonthYear.Year).Width(100).Title("Year").ClientTemplate("#: kendo.toString(TimesheetWorkDateMonthYear, 'yyyy') #");columns.Bound(o => o.TimesheetWorkDateMonthYear.Month).Width(100).Title("Month").ClientTemplate("#: kendo.toString(TimesheetWorkDateMonthYear, 'MMM') #");
I've tried adding '.Visable(false)' to the Columns but this doesn't work also.
So I am trying to do something a little odd. I have a few tables with denormalized data. I have a setup table that based on the field name returns a list of values I populate a combobox on my grid with. On my grid when I edit up create a new record it never sends over the selected value. Also, by default if that record in the grid does not have a value it says "null" instead of the placeholder which seems to defeat the whole purpose of a place holder. Any assistance would be greatly appreciated.
public class InventoryViewModel
{
public int InventoryId { get; set; }
public int ProjectId { get; set; }
public int Qty { get; set; }
public bool AuditFlag { get; set; }
public string UpdatedBy { get; set; }
public DateTime? UpdatedDt { get; set; }
public int? ProductNameId { get; set; }
public string Size { get; set; }
public string WorkTypes { get; set; }
[DisplayName("Size")]
[UIHint("NewMeterSizeDDEditor")]
public MeterSizeDDViewModel SizeList { get; set; }
[DisplayName("Work Types")]
[UIHint("WorkTypesMSEditor")]
public IEnumerable<InventoryWorkTypesMSViewModel> WorkTypesMS { get; set; }
public List<InventoryViewModel> GetList(int projectId, int? productNameId)
{
try
{
int ii = 1;
List<InventoryViewModel> model = new List<InventoryViewModel>();
model = _db.Inventories
.Select(i =>
new InventoryViewModel
{
InventoryId = i.InventoryId,
ProjectId = i.ProjectId,
Qty = i.Qty,
AuditFlag = i.AuditFlag,
ProductNameId = i.ProductNameId,
UpdatedBy = i.UpdatedBy,
UpdatedDt = i.UpdatedDt,
Size = i.Size,
WorkTypes = i.WorkTypes,
SizeList = new MeterSizeDDViewModel
{
// WorkOrderFieldDropDownValueId = -1,
Size = i.Size
}
})
.Where(i => i.ProjectId == projectId)
.Where(i => productNameId == 0 || i.ProductNameId == productNameId).ToList();
foreach(var m in model)
{
if(m.WorkTypes != null)
{
string[] workTypeArray = m.WorkTypes.Split(',');
List<InventoryWorkTypesMSViewModel> f = new List<InventoryWorkTypesMSViewModel>();
foreach(string wt in workTypeArray)
{
f.Add(new InventoryWorkTypesMSViewModel
{
Id = ii,
WorkType = wt
});
ii++;
}
m.WorkTypesMS = f.AsEnumerable();
}
}
return model.ToList();
}
catch (Exception ex)
{
StatusErrorHandlingViewModel sc = new StatusErrorHandlingViewModel();
System.Web.UI.Page page = new System.Web.UI.Page();
string loginUserID = page.User.Identity.Name;
sc.Id = -1;
sc.Class = "InventoryViewModel";
sc.Method = "GetList";
sc.User = loginUserID;
sc.Message = ex.ToString();
sc.AddError(sc);
_db.SaveChanges();
return null;
}
}
public JsonResult _PopulateNewMeterSize(string text)
{
var meterSizes = _db.WorkOrderFieldDropDownValues
.Where(v => v.WorkOrderFieldDropDown.WorkOrderField == "NewSize")
.Select(w => new MeterSizeDDViewModel
{
// WorkOrderFieldDropDownValueId = w.WorkOrderFieldDropDownValueId,
Size = w.Value
});
if (!string.IsNullOrEmpty(text))
{
meterSizes = meterSizes.Where(p => p.Size.Contains(text));
}
return Json(meterSizes, JsonRequestBehavior.AllowGet);
}
public void _PopulateNewMeterSizeViewData()
{
var meterSizes = _db.WorkOrderFieldDropDownValues
.Where(v => v.WorkOrderFieldDropDown.WorkOrderField == "NewSize")
.Select(w => new MeterSizeDDViewModel
{
// WorkOrderFieldDropDownValueId = w.WorkOrderFieldDropDownValueId,
Size = w.Value
}); //.OrderBy(v => v.WorkOrderFieldDropDownValueId).ToList();
ViewData["newSize"] = meterSizes;
ViewData["defaultNewSize"] = meterSizes.First();
}
View
<script type="text/kendo" id="WorkTypesMSTemp">
<ul>
#for(var i = 0; i< data.length; i++){#
<li>#:data[i].WorkType#</li>
#}#
</ul>
</script>
<script type="text/javascript">
var WorkTypesMSTemp = kendo.template($("#WorkTypesMSTemp").html(), { useWithBlock: false });
</script>
<h2>Inventory List</h2>
@(Html.Kendo().Grid<FS2.ViewModels.Inventory.InventoryViewModel>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(u => u.InventoryId).Visible(false);
columns.Bound(u => u.ProjectId).Visible(false);
columns.Bound(u => u.ProductNameId).Visible(false);
columns.Bound(u => u.Qty);
columns.Bound(u => u.AuditFlag);
columns.Bound(u => u.SizeList).ClientTemplate("#=SizeList.Size#");
columns.Bound(u => u.WorkTypesMS).ClientTemplate("#=WorkTypesMSTemp.WorkTypesMS#");
columns.Command(command => { command.Destroy(); }).Width(150);
})
.ToolBar(toolBar =>
{
//code to create template
toolBar.Template(@<text>
<div class="toolbarbuttons">
<a id="AddNew" class='k-button k-button-icontext k-grid-add k-state-disabled' href='#'><span class='k-icon k-add'></span>Add new record</a>
<a class='k-button k-button-icontext k-grid-save-changes' href='#'><span class='k-icon k-i-check'></span>Save</a>
@*onclick="return onSave()"*@
</div>
<div class="toolbar">
<label class="workDate-label" for="workDate">Product:</label>
@(Html.Kendo().DropDownList()
.Name("productname")
.OptionLabel("All")
.DataTextField("ProductName")
.DataValueField("ProductNameId")
.AutoBind(false)
.Events(e => e.Change("productnameprojectChange"))
.HtmlAttributes(new { style = "width: 70%;" })
.DataSource(ds =>
{
ds.Read("_PopulateProductNamesDD", "Common");
})
)
<label class="site-label" for="site">Project:</label>
@(Html.Kendo().DropDownList()
.Name("project")
.OptionLabel("All")
.DataTextField("ProjectName")
.DataValueField("ProjectId")
.AutoBind(false)
.Events(e => e.Change("projectChange"))
.HtmlAttributes(new { style = "width: 70%;" })
.DataSource(ds =>
{
ds.Read("_PopulateProjectsDD", "Common");
})
)
</div>
</text>);
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Pageable()
.Sortable()
.Scrollable()
.HtmlAttributes(new { style = "height:550px;" })
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.ServerOperation(false)
.Events(events => events
.Error("error_handler")
.Change("onChange")
)
.Model(model =>
{
model.Id(u => u.InventoryId);
model.Field(u => u.Size == u.SizeList.Size);
model.Field(u => u.WorkTypesMS).DefaultValue(new List<FS2.ViewModels.Common.InventoryWorkTypesMSViewModel>());
model.Field(u => u.SizeList).DefaultValue(
ViewData["defaultNewSize"] as FS2.ViewModels.Common.MeterSizeDDViewModel);
})
.PageSize(20)
.Read(read => read.Action("_InventoryListGrid", "Inventory").Data("onRead"))
.Create(create => create.Action("_InventoryListGridCreate", "Inventory").Data("serialize"))
.Update(update => update.Action("_InventoryListGridEdit", "Inventory").Data("serialize"))
.Destroy(destroy => destroy.Action("_InventoryListGridDestroy", "Inventory"))
)
)

I am trying to submit a form that contains localized data and numeric textboxes with decimal numbers.
The culture I use is hr-HR and decimal data numbers look like 123,45. the problem is that whenever the decimals are present, the form will not submit. I think it might be the validation because of the (,) instead of the dot, If I leave zeroes in decimal places, the form submits nicely.
How do I get the form to accept localized decimal numbers?
------------
I've realized that the NumericTextbox doesnt see comma (which are created on GET) as the decimal separator. And due to change culture I cannot use dots. So Im cornered.
Is this a bug or am I missing something?
Hi I have a hidden div that is initiated as a popup window.
The window works fine - dynamically changed title, centre and opens. Unfortunately despite it being set as modal: true it does not display the overlay or behave as a modal.
Below is a html file that demonstrates my problem... Where have I gone wrong?
<!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"><head> <meta charset="utf-8" /> <title></title> <link href="http://localhost/DCHR_MVC/Content/bootstrap.css" rel="stylesheet" type="text/css" /> <link href="http://localhost/DCHR_MVC/Content/font-awesome.css" rel="stylesheet" type="text/css" /> <link href="http://localhost/DCHR_MVC/Content/kendo/2018.2.516/kendo.common.min.css" rel="stylesheet" type="text/css" /> <link href="http://localhost/DCHR_MVC/Content/kendo/2018.2.516/kendo.common-bootstrap.min.css" rel="stylesheet" type="text/css" /> <link href="http://localhost/DCHR_MVC/Content/kendo/2018.2.516/kendo.mobile.all.min.css" rel="stylesheet" type="text/css" /> <link href="http://localhost/DCHR_MVC/Content/kendo/2018.2.516/kendo.bootstrap.min.css" rel="stylesheet" type="text/css" /> <link href="http://localhost/DCHR_MVC/CSS/SiteStyles.css" rel="stylesheet" type="text/css" /> <script src="http://localhost/DCHR_MVC/Scripts/jquery-3.3.1.min.js"></script> <script src="http://localhost/DCHR_MVC/Scripts/umd/popper.js"></script> <script src="http://localhost/DCHR_MVC/Scripts/bootstrap.min.js"></script> <script src="http://localhost/DCHR_MVC/Scripts/respond.js"></script> <script src="http://localhost/DCHR_MVC/Scripts/kendo/2018.2.516/jszip.min.js"></script> <script src="http://localhost/DCHR_MVC/Scripts/kendo/2018.2.516/kendo.all.min.js"></script> <script src="http://localhost/DCHR_MVC/Scripts/kendo/2018.2.516/kendo.aspnetmvc.min.js"></script> <script src="http://localhost/DCHR_MVC/Scripts/kendo.modernizr.custom.js"></script></head><body> <div class="btn-group"> <button id="btnCapacity" type="button" class="btn btn-info" data-toggle="tooltip" onclick="approveDCHR('Capacity')">Capacity Approval</button> <button id="btnTechnical" type="button" class="btn btn-secondary" data-toggle="tooltip" onclick="approveDCHR('Technical')">Technical Approval</button> <button id="btnOverall" type="button" class="btn btn-primary" data-toggle="tooltip" onclick="approveDCHR('Overall')">Overall Approval</button> </div> <div id="approvalWindow" style="display:none;"> <div class="card"> <div class="card-header">Comments <i class="fa fa-info-circle" data-toggle="tooltip" title="Approval Comments (mandatory)"></i></div> <div class="card-body"> <textarea id="nApprovalComments" class="form-control w-95" placeholder="Please enter comments"></textarea> </div> </div> <div class="card"> <div class="card-header">Approved By <i class="fa fa-info-circle" data-toggle="tooltip" title="Approved By (cannot be changed)"></i></div> <div class="card-body"> <input id="nApprovalBy" class="form-control w-95" readonly /> </div> </div> <div class="card"> <div class="card-header">Date <i class="fa fa-info-circle" data-toggle="tooltip" title="Date approved (cannot be changed)"></i></div> <div class="card-body"> <input id="nApprovalDate" class="form-control w-95" readonly /> </div> </div> <div class="card"> <div class="btn-group justify-content-between"> <button class="btn btn-info w-25" onclick="approvalClose()">Cancel</button> <button class="btn btn-warning w-25" onclick="approvalClear()">Clear</button> <button class="btn btn-success w-25" onclick="approvalSave()">Save</button> </div> </div> </div></body></html><script> var approvalWindow = $("#approvalWindow"); function approveDCHR(stage) { // reset the appovals window to default values approvalClear(); //set window title and open centered on screen var wnd = approvalWindow.kendoWindow().data("kendoWindow"); console.log(wnd); wnd.title(stage + " Approval"); wnd.refresh(); wnd.center(); wnd.open(); //make texarea autogrow - requires jquery.ns-autogrow - https://github.com/ro31337/jquery.ns-autogrow //$('#nApprovalComments').autogrow({ vertical: true, horizontal: false }); } function approvalClose() { approvalWindow.kendoWindow().data("kendoWindow").close(); } function approvalClear() { // reset the appovals window to default values $('#nApprovalComments').val(""); $('#nApprovalBy').val(""); $('#nApprovalDate').val(new Date()); } function approvalSave() { approvalWindow.kendoWindow().data("kendoWindow").close(); } $(document).ready(function () { //initiate popup window approvalWindow.kendoWindow({ width: "570px", title: "Approval", actions: "", modal: true, visible: false }).data("kendoWindow").close(); });</script>
Hi,
I'm creating a master-detail grid (see the screenshot attached) and I need the following:
Both grids uses local data binding, once the controller returns the view I don't wanna access the server again to read the data of the grids. Here's my code
The view:
01.@(Html.Kendo().Grid(Model.ExpedienteRows)02. .Name("grid_SeleccionarPedidos")03. .Columns(columns =>04. {05. columns.Bound(c => c.IdExpediente).Hidden();06. columns.Bound(c => c.Seleccionado)07. .Width(90);08. columns.Bound(c => c.Autor).Width(190);09. columns.Bound(c => c.AnnoExpediente)10. .Title("Año")11. .Width(70);12. columns.Bound(c => c.NumeroExpediente)13. .Title("Número")14. .Width(120);15. })16. .Editable(ed => ed.Mode(GridEditMode.InCell))17. .HtmlAttributes(new { style = "height: 380px; with: 200px;" })18. .Scrollable(x => x.Height(300))19. .Sortable(x => x.SortMode(GridSortMode.MultipleColumn))20. .Filterable()21. .DataSource(dataSource => dataSource22. .Ajax()23. .ServerOperation(false)24. .Batch(true)25. .Model(model =>26. {27. model.Id(p => p.IdExpediente);28. })29. )30. .ClientDetailTemplateId("pedidos")31. .Events(e => e.DetailInit("detailInit"))32.)33. 34.<script id="pedidos" type="text/kendo-tmpl">35. @(Html.Kendo().Grid<PedidoRow>()36. .Name("gridPedido_#=IdExpediente#")37. .Columns(columns =>38. {39. columns.Bound(c => c.IdPedido).Hidden();40. columns.Bound(c => c.Seleccionado)41. .Width(40);42. columns.Bound(c => c.AnnoPedido).Width(70);43. columns.Bound(c => c.NumeroPedido).Width(70);44. columns.Bound(c => c.Proveedor).Width(70);45. columns.Bound(c => c.DescripcionMaterial).Width(70);46. columns.Bound(c => c.Importe)47. .Format("{0:N4}")48. .Width(70);49. })50. .HtmlAttributes(new { style = "with: 200px;" })51. .ToClientTemplate()52. )53.</script>54. 55.<script>56. function detailInit(e) {57. var grid = $("#gridPedido_" + e.data.IdExpediente).data("kendoGrid");58. grid.dataSource.data(e.data.Pedidos);59. }60.</script>and here's the model
01.public class SeleccionarPedidosModel02.{03. public IEnumerable<ExpedienteRow> ExpedienteRows { get; set; }04.}05. 06.public class ExpedienteRow07.{08. public bool Seleccionado { get; set; } // binded to the first column (checkbox)09. public Guid IdExpediente { get; set; }10. public string Autor { get; set; }11. public int NumeroExpediente { get; set; }12. public int AnnoExpediente { get; set; }13. public IEnumerable<PedidoRow> Pedidos { get; set; } // Detail grid content14.}15. 16.public class PedidoRow17.{18. public Guid IdPedido { get; set; }19. public bool Seleccionado { get; set; } // binded to the first column (checkbox)20. public int NumeroPedido { get; set; }21. public int AnnoPedido { get; set; }22. public string Proveedor { get; set; }23. public string DescripcionMaterial { get; set; }24. public decimal Importe { get; set; }25.}
Any help will be appreciated
Thanks.