Hi,
I'm trying to minimize the height of the listbox because of layout restrictions. Played around with css (beginner here) a little but need help on how I can reduce the spacing between toolbar buttons so that I can further reduce the height - see attached image?
(Bootstrap 4 styling)
Kind regards
Erwin
I'm brand new to ASP.net core MVC and Telerik, and my first post in the forums is a plea for help getting a demo up and running in VS 2015.
I downloaded and installed a trial of Telerik's UI for ASP.NET MVC, and opened the Kendo.Mvc.Examples solution.
Immediately, I am now faced with two problems which, despite hours of searching here and elsewhere, cannot be solved without help from the forums. This doesn't give me much confidence, and has led to hours of frustration.
Problem 1:
The compiler reports that Microsoft.Web.Infrastructure version=1.0.0.0 could not be found.
Problem 2:
The Sample.mdf database requires Sql Server Express 2012 Localdb. I have SQL Server 2016 installed. I even installed SQL Server 2012 express, and it still doesn't let me use the sample.mdf database.

I have a view that has three comboboxes, a submit button and a batch editable grid.
I'm not sure I have it wired up correctly as most items work. The problem I am having is that my grid is not refreshed after I update.
Steps
1. Call the Index action which returns an empty list to the grid model(to start)
2. Type in a character into the store combobox, which calls an action to populate, and then select one of them
3. Leave the status combobox at Assigned
4. Click the search button
5. Edit the status of one of the items
6. Click save
Save appears to work but my grid should show one less row based on search criteria(as I changed the status of one of them).
Models
[Table("Images")]
public class SearchResult
{
[Key]
public int ImageId { get; set; }
public int StatusId { get; set; }
public string Name { get; set; }
[Required]
public string Description { get; set; }
public int ProjectId { get; set; }
public int StoreId { get; set; }
}
public class Store
{
public int Id { get; set; }
public string Name { get; set; }
}
public class Project
{
public int Id { get; set; }
public string Name { get; set; }
}
View
@model List<PhotoReviewTelerik.Models.SearchResult>
@{
ViewBag.Title = "PhotoReview";
}
<h2>PhotoReview</h2>
<form method="get" action="@Url.Action("Search")" data-pr-ajax="true" data-pr-target="#searchResults">
<div class="demo-section k-content">
<h4>Projects</h4>
@(Html.Kendo().ComboBox()
.Name("projects")
.DataTextField("Name")
.DataValueField("Id")
.Placeholder("Select Project")
.Filter("contains")
.AutoBind(false)
.MinLength(1)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetProjects", "PhotoReview");
})
.ServerFiltering(true);
})
)
<div class="demo-hint">Hint: type at least three characters. For example "pro".</div>
</div>
<div class="demo-section k-content">
<h4>Stores</h4>
@(Html.Kendo().ComboBox()
.Name("stores")
.DataTextField("Name")
.DataValueField("Id")
.Placeholder("Select Store")
.Filter("contains")
.AutoBind(false)
.MinLength(1)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetStores", "PhotoReview");
})
.ServerFiltering(true);
})
)
<div class="demo-hint">Hint: type at least three characters. For example "sto".</div>
</div>
@(Html.Kendo().ComboBox()
.Name("status")
.BindTo(new List<string>() {
"Assigned",
"Reviewed"
})
.SelectedIndex(0)
.Suggest(true)
)
<div>
@(Html.Kendo().Button()
.Name("primaryTextButton")
.HtmlAttributes(new { type = "submit", @class = "k-primary" })
.Content("Search"))
</div>
</form>
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.ImageId).Title("ImageId");
columns.Bound(p => p.StatusId).Title("Status");
columns.Bound(p => p.Name).Title("Name");
columns.Bound(p => p.Description).Title("Description");
columns.Bound(p => p.ProjectId).Title("ProjectId");
columns.Bound(p => p.StoreId).Title("StoreId");
})
.ToolBar(toolbar =>
{
toolbar.Save().SaveText("Save").CancelText("Cancel"); // The "save" command saves the changed data items.
})
.HtmlAttributes(new { style = "height: 550px;" })
.NoRecords()
.Pageable(pageable => pageable
.Input(true)
.Numeric(false)
)
.Sortable()
.Scrollable(scr => scr.Height(430))
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.Events(events => events.Error("error_handler"))
//.Events(events =>
//{
// events.RequestEnd("onRequestEnd"); //I've added this
//})
.Batch(true)
.Model(model =>
{
model.Id(i => i.ImageId); // Specify the property which is the unique identifier of the model.
model.Field(i => i.ImageId).Editable(false); // Make the ImageId property not editable.
model.Field(i => i.Name).Editable(false); //
model.Field(i => i.ProjectId).Editable(false);
model.Field(i => i.StoreId).Editable(false);
})
.PageSize(20)
.ServerOperation(false)
.Update(update => update.Action("Update", "PhotoReview").Data("additionalData"))
//.Read(read=>read.Action("Search", "PhotReview").Data("additionalData"))
)
.Editable(editable => editable.Mode(GridEditMode.InCell))
)
<script>
function additionalData() {
return {
Project: getUrlParameter('projets'),
Store: getUrlParameter('stores'),
Status: getUrlParameter('status')
};
}
function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];
}
}
};
function error_handler(e) {
if (e.errors) {
var message = "Errors:\n";
$.each(e.errors, function (key, value) {
if ('errors' in value) {
$.each(value.errors, function () {
message += this + "\n";
});
}
});
alert(message);
}
}
//function onRequestEnd(e) {
// if (e.type === "update") {
// var grid = $('#Grid').data('kendoGrid');
// grid.dataSource.read();
// }
//}
</script>
@Html.ValidationSummary(false, "", new { @class = "text-danger" })
Controller
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using PhotoReviewTelerik.Models;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace PhotoReviewTelerik.Controllers
{
public class PhotoReviewController : Controller
{
private PhotoReviewTelerikDb db = new PhotoReviewTelerikDb();
// GET: PhotoReview
public ActionResult Index()
{
var model = new List<SearchResult>();
return View("PhotoReview", model);
}
public ActionResult Search(int? projects, int? stores, string status)
{
int tempStatus = 0;
if (status == "Assigned")
tempStatus = 0;
else
tempStatus = 1;
var model = db.SearchResults.ToList();
model = model.Where(p => p.StatusId == tempStatus).ToList();
if (projects.HasValue)
model = model.Where(p => p.ProjectId == (int)projects).ToList();
if (stores.HasValue)
model = model.Where(p => p.StoreId == (int)stores).ToList();
return View("PhotoReview", model);
}
public ActionResult Update([DataSourceRequest]DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<SearchResult> results, SearchCriteria criteria)
{
// Will keep the updated entitites here. Used to return the result later.
var entities = new List<SearchResult>();
if (ModelState.IsValid)
{
using (var db = new PhotoReviewTelerikDb())
{
foreach (var result in results)
{
// Create a new Product entity and set its properties from the posted ProductViewModel.
var entity = new SearchResult
{
ImageId = result.ImageId,
StatusId = result.StatusId,
Name = result.Name,
Description = result.Description,
ProjectId = result.ProjectId,
StoreId = result.StoreId
};
// Store the entity for later use.
entities.Add(entity);
// Attach the entity.
db.SearchResults.Attach(entity);
// Change its state to Modified so Entity Framework can update the existing product instead of creating a new one.
db.Entry(entity).State = EntityState.Modified;
// Or use ObjectStateManager if using a previous version of Entity Framework.
// northwind.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified);
}
// Update the entities in the database.
db.SaveChanges();
}
//redirect to search
return RedirectToAction("Search", new { projects = criteria.Project, stores = criteria.Store, status = criteria.Status });
}
else
{
//return View("PhotoReview", results);
return Json(entities.ToDataSourceResult(request, ModelState, result => new SearchResult
{
ImageId = result.ImageId,
StatusId = result.StatusId,
Name = result.Name,
Description = result.Description,
ProjectId = result.ProjectId,
StoreId = result.StoreId
}));
}
}
public JsonResult GetStores(string text)
{
text = text.Trim();
if(!string.IsNullOrEmpty(text))
{
var model = db.Stores.ToList();
model = model.Where(s => s.Name.ToLower().Contains(text.ToLower())).ToList();
return Json(model, JsonRequestBehavior.AllowGet);
}
return Json(new List<Store>(), JsonRequestBehavior.AllowGet);
}
public JsonResult GetProjects(string text)
{
text = text.Trim();
if (!string.IsNullOrEmpty(text))
{
var model = db.Projects.ToList();
model = model.Where(s => s.Name.ToLower().Contains(text.ToLower())).ToList();
return Json(model, JsonRequestBehavior.AllowGet);
}
return Json(new List<Project>(), JsonRequestBehavior.AllowGet);
}
}
}
I noticed that the TreeView widget is behaving totally different when using BindTo(myViewModel.GroupList) versus using DataSource(<calling an action on a controller>). The problem: when using DataSource all additional fields like "Expanded" or "HtmlAttributes" are ignored by the TreeView widget so the TreeView looks different depending on which way I use it.
myViewModel.GroupList is a List<TreeViewItemModel>, the action on my Controller returns a JsonResult(List<TreeViewItemModel>,...). In fact both are exactly the same lists.
The code for DataSource is as follows:
.DataTextField("Text").DataSource(ds => ds .Read(read => read.Url(SettingsManager.BaseServiceUrl + "/groups/all/").Type(HttpVerbs.Get)) .Model(model => { model.Id("Id"); model.Children("Items"); model.HasChildren("HasChildren"); }))
Any idea why this happens?
Regards
Heiko

Hi Team,
I have a simple MVC diagram, which works on Chrome but throws error on Internet Explorer. I do not have a clue. Please find the code below in Razor View. Please help.
It says onDataBound is undefined and cannot find property bringIntoView.
@model dotGrantsApps.Areas.Maintenance.Models.WorkflowViewModel
@using Kendo.Mvc.UI
@{
ViewBag.Title = "Workflow Chart";
@Html.Hidden("hdnWorkflowId", Model.OtcId);
}
@(Html.Kendo().Diagram()
.Name("workflowOverviewDiagram")
.DataSource(dataSource => dataSource
.Read(read => read.Action("GetWorkflowStopData", "WorkflowMaintenance", new { area = "Maintenance", workflowDefinitionId = Model.OtcId }))
.Model(m => m.Children("Items"))
)
.Editable(false)
.Layout(l => l
.HorizontalSeparation(400)
.VerticalSeparation(200)
.Type(DiagramLayoutType.Tree).Subtype(DiagramLayoutSubtype.Down)
)
.ShapeDefaults(sd => sd.Visual("visualTemplate"))
.ConnectionDefaults(cd => cd
.EndCap("ArrowEnd")
.Stroke(s => s
.Color("#979797")
.Width(2)
)
)
.ZoomRate(0)
.Selectable(false)
.Events(events => events.DataBound("onDataBound"))
)
<script>
function visualTemplate(options) {
var dataviz = kendo.dataviz;
var g = new dataviz.diagram.Group();
var dataItem = options.dataItem;
var layout = new dataviz.diagram.Layout(new dataviz.diagram.Rect(0, 0, 210, 75), {
alignContent: "center",
spacing: 4
});
g.append(new dataviz.diagram.Rectangle({
width: 210,
height: 75,
stroke: {
width: 0
},
fill: {
gradient: {
type: "linear",
stops: [{
color: "#133781"
}]
}
}
}));
g.append(layout);
var texts = dataItem.WorkflowStopName.split(" ");
for (var i = 0; i < texts.length; i++) {
layout.append(new dataviz.diagram.TextBlock({
text: ' ' + texts[i],
color: "#fff"
}));
}
layout.reflow();
return g;
}
function onDataBound() {
this.bringIntoView(this.shapes);
}
</script>
Hi there,
I'm using kendo PanelBar with foreach for the nested contents, here is the code:
<div class="col-lg-12">
@(Html.Kendo().PanelBar()
.Name("OrganizerTour")
.ExpandMode(PanelBarExpandMode.Multiple)
.HtmlAttributes(new { style = "" })
.Items(panelbar =>
{
foreach (var result in Model)
{
panelbar.Add().Text("Organizer: " + @result.organizerName).Expanded(true)
.Items(tour =>
{
tour.Add().Expanded(true).Content(@<div class="panel-content">
<div class="row dashboard-grid">
@RenderGrid(result.Result)
</div>
</div>);
});
}
})
)
</div>
When each PanelBar is expanded, there are two arrows showing (see attached) - it's fine when collapsed.
How can I remove the bottom arrow? Or is it something wrong with the codes above?

Hi there,
Not sure why when hovering over the datetime picker it cuts-off the datetime textbox.
Here's the razor code:
<div class="col-md-4"> @(Html.Kendo().DateTimePicker().Name("EntryDate3").Value("2018-05-31").HtmlAttributes(new { type = "text" })) </div>
See attached screenshot of the textbox when hovered over.
Anybody can point out what I did wrong?
Thanks.
Hi, I'm using a ListBox with a template.
<script id="roleChoiceTemplate" type="text/x-kendo-template">
<div class="row"><div class="col-sm-9"> #: data.RoleName #</div> <div class="col-sm-3">#: data.RoleNeedsAttention == true ? 'Y' : ''#</div></div>
</script> @(Html.Kendo().ListBox() .Name("roleChoices") .DataTextField("RoleName") .DataValueField("RoleName") .TemplateId("roleChoiceTemplate") .HtmlAttributes(new { style = "width: 100%; overflow: hidden;" }) .DataSource(source => source .Read(read => read.Action("GetRoles", "Home")) ) )As is, this works fine, but instead of displaying a 'Y' in the template when the value is true, I want to display a formatted span like <span class=\'needsAttention\'>Attention</span>. When I try to do this, I either see the text '<span>...' or with different alterations I get an invalid template javascript error. Can you help me get the syntax right because I'm out of ideas.
Thanks!

Hello,
I try to load child nodes on parent's expansion with the data remote binding.
But when i do like the exemple (https://demos.telerik.com/aspnet-mvc/treelist/remote-data-binding) My first level is correctly loaded but I can't expand them beacause there is no icon to do it on my treelist. See Screenshot there
I got the same issue on your sample application. I runned your solution and there is no icon to expand parent also. See screenshot
My current kendo version is 2017.2.504.545.
Also, I found on the forum another user who has the same problem (https://www.telerik.com/forums/mvc-treelist-load-on-demand, see the end of the topic)
There is my treelist view
@(Html.Kendo().TreeList(Model) .Name("hierarchyTreelist") .Toolbar(x => { if (ViewBag.Mode == TypeArbo.MP.ToString()) { x.Create().Text(" "); } }) .Editable(editable => editable.Mode("popup").TemplateName("HierarchyPopUpEditor")) .Sortable() .Filterable(ftb => ftb.Extra(false)) .Resizable(true) .Scrollable(true) .ColumnMenu() .Columns(columns => { columns.Add().Field(e => e.Id).Hidden(true); columns.Add().Field(e => e.Libelle); columns.Add().Field(e => e.Code).Width(140); columns.Add().Field(e => e.CodeParent).Width(140); columns.Add().Field(e => e.CodeEtLibelleUbaldi).Width(200).Hidden(ViewBag.Mode == TypeArbo.Ubaldi.ToString()); columns.Add().Field(e => e.FamilleLogistiqueNom).Width(250).Hidden(ViewBag.Mode == TypeArbo.Ubaldi.ToString()); columns.Add().Field(e => e.IsActif).Template("#= IsActif ? 'Oui' : 'Non' #").Width(100); columns.Add().Title("Attributs").Command(c => { c.Custom().Click("AttributView").Text(" ").Name("btnEditHierarchyAttribut").ImageClass("glyphicon glyphicon-th-list").ClassName("btn btn-info"); }).Width(80); if (ViewBag.Mode == TypeArbo.MP.ToString()) { columns.Add().Command(c => { c.CreateChild().Text(" ").ClassName("btn btn-success"); c.Edit().Text(" ").ClassName("btn btn-primary"); c.Custom().Click("MoveView").Text(" ").Name("btnMoveHierarchy").ImageClass("glyphicon glyphicon-move").ClassName("btn btn-warning"); c.Custom().Click("DeleteView").Text(" ").Name("btnDeleteHierarchy").ImageClass("k-i-trash").ClassName("btn btn-danger"); }).Width(250); } }) .DataSource(dataSource => dataSource .Create(create => create.Action("Create", "Hierarchie")) .Update(update => update.Action("Update", "Hierarchie")) .Destroy(destroy => destroy.Action("Delete", "Hierarchie")) .Read(read => read.Action("GetHierarchies", "Hierarchie", new { typeArbo = ViewBag.Mode, txtCode = Code, txtLibelle = Libelle, txtParent = CodeParent, txtFamLogi = FamLogi, rdblIsActif = IsActif })) .Model(m => { m.Id(f => f.Code); m.ParentId(f => f.CodeParent); m.Field(f => f.Libelle); m.Field(f => f.IsActif); m.Field(f => f.Description); m.Field(f => f.URL); m.Expanded(false); }) ) .Events(e => { e.Edit("OnEdit"); e.Save("OnSave"); }))
And there my data controller action :
public JsonResult GetHierarchies([DataSourceRequest] DataSourceRequest request,string id, TypeArbo typeArbo, string txtCode, string txtLibelle, string txtParent, string txtFamLogi, bool? rdblIsActif) { List<PIMHierarchy> list = new List<PIMHierarchy>(); if (rdblIsActif != null) list = hierarchyManager.GetByParams(txtCode, txtLibelle, txtParent, txtFamLogi, typeArbo) .Where(h => ((bool)rdblIsActif && h.IsActif || !(bool)rdblIsActif && !h.IsActif)).ToList(); else list = hierarchyManager.GetByParams(txtCode, txtLibelle, txtParent, txtFamLogi, typeArbo).ToList(); TreeDataSourceResult result = result = list.ToTreeDataSourceResult(request, e => e.Code, e => e.CodeParent, e => id != null ? e.CodeParent == id : e.CodeParent == string.Empty, e => e ); return Json(result, JsonRequestBehavior.AllowGet);}
Do you have any ideas where the problem is ?
Thank you for you time on that issue,
