I added a resource using the following code:
var scheduler = $("#scheduler").data("kendoScheduler");
scheduler.resources[0].dataSource.add({
Text: "aaaaaBBBBBB",
Value: 23,
Color: "#FFFFFF"
});
scheduler.view(scheduler.view().name);
How can I get the resources to sort by Text so that it shows up in order and not at the end?

I am using a Kendo MVC Scheduler control with a TimeLine view and I am adding new events via an ajax call to my server to add to a table that holds scheduler events. I need a way to refresh the scheduler or to add an event manually just so it will show up until the next refresh. Is there an easy way to do that?
I tried the following but it doesn't call my read method:
var scheduler = $("#scheduler").data("kendoScheduler");
scheduler.resources[0].dataSource.read().then(
function () {
scheduler.view(scheduler.view().name);
});
This is my client side code:
<% Html.Kendo().Scheduler<WheresMyTool.Models.MeetingViewModel>()
.Name("scheduler")
.Date(new DateTime(2016, 12, 16))
.StartTime(new DateTime(2016, 12, 16, 7, 00, 00))
.MajorTick(60)
.EventTemplate(
"<div class='#= eventStyle #' title='#= description #'>" +
"#= title #" +
"</div>")
.Views(views =>
{
views.TimelineWeekView(timeline =>
{
timeline.EventHeight(25);
timeline.ColumnWidth(1);
});
views.TimelineView(timeline =>
{
timeline.EventHeight(25);
timeline.ColumnWidth(10);
});
views.TimelineMonthView(timeline =>
{
timeline.StartTime(new DateTime(2016, 12, 16, 00, 00, 00));
timeline.EndTime(new DateTime(2016, 12, 16, 00, 00, 00));
timeline.MajorTick(1440);
timeline.MinorTickCount(1);
timeline.EventHeight(25);
timeline.ColumnWidth(10);
});
})
.Editable(a => a.Confirmation(false))
.Timezone("Etc/UTC")
.Group(group => group.Resources("Attendees").Orientation(SchedulerGroupOrientation.Vertical))
.Events(e =>
{
e.DataBound("schedulerDataBound");
e.Edit("scheduler_edit");
e.Add("scheduler_add");
})
.Resources(resource =>
{
resource.Add(m => m.Attendees)
.Title("Attendees")
.Name("Attendees")
.Multiple(true)
.DataTextField("Text")
.DataValueField("Value")
.DataColorField("Color")
.BindTo(Model.resourceList);
})
.DataSource(d => d
.AutoSync(true)
.Read("SchedulerRead", "Scheduler")
.Create("SchedulerCreate", "Scheduler")
).Render();
%>

Hi,
I was hoping someone could help me with the issue I have in storing the order of sortable panels within the local storage.
Here is some example code I am using:
-----------------------------------------------------------------------------------------
.........
string name = string.Format("main-content{0}", colCounter);
<div id = "@name" >
@{
foreach (var colItem in cols)
{
@renderTiles(colItem);
}
}
</div>
..................
@(Html.Kendo().Sortable()
.For("#main-content1")
.ConnectWith("#main-content2,#main-content3")
.Cursor("move")
.PlaceholderHandler("placeholder")
.HintHandler("hint")
)
@(Html.Kendo().Sortable()
.For("#main-content2")
.ConnectWith("#main-content1,#main-content3")
.Cursor("move")
.PlaceholderHandler("placeholder")
.HintHandler("hint")
)
@(Html.Kendo().Sortable()
.For("#main-content3")
.ConnectWith("#main-content1, #main-content2")
.Cursor("move")
.PlaceholderHandler("placeholder")
.HintHandler("hint")
)
.............
<script>
var localStorageSupport = (('localStorage' in window && window['localStorage'] !== null)),
data,
html;
if (localStorageSupport) {
data = JSON.parse(localStorage.getItem("sortableData"));
} else {
alert("your browser does not support local storage");
}
$(document).ready(function ()
{
$('.widget').click(function (e) {
window.location.href = $(e.target).attr('href');
})
$('.widget').change(function (e) {
var item = data.splice(e.oldIndex, 1)[0];
data.splice(e.newIndex, 0, item);
localStorage.setItem("sortableData", kendo.stringify(data))
})
})
</script>
@helper renderTiles(IPublishedContent Section)
{
var title = Section.GetPropertyValue<string>("tiitle", String.Empty);
var icon = Section.GetPropertyValue<string>("icon", String.Empty);
int intLink = Section.GetPropertyValue<int>("intLink", 0);
var extLink = Section.GetPropertyValue<string>("extLink", String.Empty);
var imgId = Section.GetPropertyValue("icon", -1);
var Url = string.Empty;
if (@intLink == 0 && @extLink.Length > 0)
{
Url = @extLink;
}
else if (@intLink != 0 && @extLink.Length == 0)
{
Url = Umbraco.NiceUrl(@intLink);
}
<div id="panes" class="widget" header="@title" href="@Url">
<div header="@title" href="@Url">
@title
<div class="widget-image" header="@title" href="@Url">
@if (imgId != -1)
{
<img src="@Umbraco.TypedMedia(imgId).Url" alt="=@Umbraco.TypedMedia(imgId).Name" title="@title" header="@title" href="@Url" />
}
</div>
</div>
</div>
}
I have looked at the following:
http://docs.telerik.com/kendo-ui/controls/interactivity/sortable/overview
http://docs.telerik.com/kendo-ui/controls/interactivity/sortable/how-to/persist-order-in-localstorage
http://www.telerik.com/forums/saving-sortable-state
These do make sense but I am having a bit of a senior moment with what I am trying to do.
Many thanks.
J
@model IEnumerable<HCS.Model.FinancialInstitution>@(Html.Kendo().Grid(Model) .Name("Grid") .Columns(columns => { columns.Bound(p => p.MainRT).Groupable(false); columns.Bound(p => p.LegalName); }) .Pageable() .Sortable() .Scrollable() .Filterable() .DataSource(dataSource => dataSource .Ajax() .ServerOperation(false)))@model IEnumerable<HCS.Model.FinancialInstitution>@(Html.Kendo().Window() .Name("window") .Title("Choose a Financial Institution (FI)") .Content(() => { @Html.Kendo().Grid(Model) .Name("Grid") .Columns(columns => { columns.Bound(p => p.MainRT).Groupable(false); columns.Bound(p => p.LegalName); }) .Pageable() .Sortable() .Scrollable() .Filterable() .DataSource(dataSource => dataSource .Ajax() .ServerOperation(false)); }) .Draggable() .Resizable() .Events(ev => ev.Close("onClose")) .Width(400) )
I am unable to figure out why the HttpPostedFileBase is always null in my upload widget. Sample Project showing the issue.
View
@using (Html.BeginForm()){ @Html.AntiForgeryToken() <div class="row row-spacing-bottom"> <div class="col-md-12"> @(Html.Kendo().Upload() .Name(Html.IdFor(model => model.HttpPostedFileBase).ToString()) .Multiple(false) .Messages(m => m.Select("Select a File")) .Events(e => e.Select("uploadHelper.checkFileSize")) .Deferred()) </div> </div> <div class="row"> <div class="col-md-12"> @(Html.Kendo().Button() .Name("Submit") .Content("Upload File") .HtmlAttributes(new {type = "submit"}) .Deferred()) </div> </div>}
Controller:
public class FileUploadController : Controller { public ActionResult FileUpload() { return View(); } [HttpPost] [ValidateAntiForgeryToken] public ActionResult FileUpload(Models.FileUpload fileUpload) { var result = fileUpload.HttpPostedFileBase != null; return Json(new {success = result}); } }
Submit function:
$('form').submit(function () { layout.showLoadingScreen(true); $.ajax({ url: this.action, type: this.method, data: $(this).serialize(), success: function (result) { if (result.success) { layout.showNotification("Save Successful", "success"); layout.showLoadingScreen(false); } else { layout.showNotification("Error Saving Record", "error"); layout.showLoadingScreen(false); } } }); return false; });
Hello guys.
Unfortunately, I've found an error in Kendo (there is no such error in 2015.3.930.545 (just for information))
Check the example project.
https://www.dropbox.com/s/7h8gm1ekyui56qq/KendoUI.rar?dl=0
Description:
- I have two grids.
- They both have a field "Volume" and calculate the sum of this field.
- They don't have any other aggregates for other fields. (it's important)
What I have:
1) Static class "ClassFactory" ("~/Infrastructure/Implementation/ClassFactory.cs") which has a variable Dictionary<Signature, Type> classes.
2) Class "Signature" ("~/Infrastructure/Implementation/Signature.cs") that has a method "Equals"
3) ArgumentException
Description:
When one of grid sends a request to controller, some manipulations are performed and we find ourselves in "ClassFactory" in a method "GetDynamicClass". Here a variable (name - signature) of type "Signature" is added to the variable "classes" of type "Dictionary<Signature, Type>". No problems, everything is fine. Then another grid does the same steps. But now, when the variable "signature" is being added to the variable "classes", I get exception "ArgumentException". Why? Look at the code of the method "Equals" of the class 'Signature':
if (poperties.Length != other.properties.Length) return false;
for (int i = 0; i < properties.Length; i++)
{
if (properties[i].Name != other.properties[i].Name || properties[i].Type != other.properties[i].Type)
return false;
}
return true;
Aggregates for the first grid: Sum_Volume for the field "Volume"
Aggregates for the second grid: Sum_Volume for the field "Volume"
Conclusion:
Aggregates are the same, so the method "Equals" returns true
And that's why I get "ArgumentException" (An item with the same key has already been added)
Solution:
People who have the same error:
You can:
1) Add the hidden field to the grid (to the model) and aggregate sth (for ex: sum) for this field. (if you have more than 2 grids with such problem, don't forget that these hidden fields must have different names, otherwise it won't help)
2) You can rename a field in one of the grids
3) Wait until Kendo fixes it :)
4) Maybe someone has another idea?!

I have the following code. i was able to determine the click on a row. but cant get the popup form to open when the row is selected.
@(Html.Kendo().Grid<grid.Model.entity>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.phone).Title("Phone").HeaderHtmlAttributes(new { style = "font-size:13px;" });
columns.Bound(p => p.address).Title("Home Address").HeaderHtmlAttributes(new { style = "font-size:13px;" });
columns.Bound(p => p.email).Title("Email").HeaderHtmlAttributes(new { style = "font-size:13px;" });
})
.ToolBar(toolbar =>
toolbar.Create()
)
.Editable(ed => ed.Mode(GridEditMode.PopUp))
.Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
.Pageable()
.Sortable()
.Scrollable()
.HtmlAttributes(new { style = "height:730px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(30)
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.ID))
.Create(update => update.Action("EditingPopup_Create", "Welcome"))
.Read(read => read.Action("Info", "Welcome").Data("searchText"))
.Update(update => update.Action("EditingPopup_Update", "Welcome"))
)
.Resizable(resize => resize.Columns(true))
)
<script type="text/javascript">
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);
}
}
$('table').click(function () {
var grid = $("#grid").data('kendoGrid');
grid.select().each(function () {
// how to open the form from here?
})
});
</script>

Hi,
We are using Kendo Data Grid, we are trying to edit the record that will go to a new page (cshtml) and passing a parameter like the ID.
Below is the code but it is not working at all. Please advise, TIA.
index.cshtml
@(Html.Kendo().Grid<iOneDistribution.Web.Models.Users.UserViewModel>()
.Name("grid")
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(u => u.UserCode))
.Read(read => read.Action("Users_Read", "Users"))
.Update(update => update.Action("Update", "Users"))
)
.Columns(columns =>
{
columns.Command(c => c.Edit());
columns.Bound(c => c.UserCode);
columns.Bound(c => c.Acronym);
columns.Bound(c => c.IsActive);
columns.Bound(c => c.IsAllowApprove);
columns.Bound(c => c.DefaultCulture);
})
.Pageable()
.Sortable(sortable =>
{
sortable.SortMode(GridSortMode.SingleColumn);
})
.Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("_UserEdit"))
.Filterable()
.Scrollable()
)
for the _useredit.cshtml
@model iOneDistribution.Web.Models.Users.UserViewModel
<h3>Customized Person edit template</h3>
<br />
@Html.HiddenFor(model => model.UserCode)
<div>
@Html.LabelFor(model => model.Name)
</div>
<div>
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<div>
@Html.LabelFor(model => model.UserGroupCode)
</div>
<div>
@*@Html.Kendo().DateTimePickerFor(model => model.BirthDate)
@Html.ValidationMessageFor(model => model.BirthDate)*@
</div>

I have implemented some server-side validation to prevent overlaps from occurring, but if an event fails twice in a row, it disappears entirely from the scheduler.
My scheduler is as follows:
@(Html.Kendo().Scheduler<MyEventViewModel>() .Name("Scheduler") .Date(DateTime.Today) .StartTime(DateTime.Today.AddHours(8)) .Height(500) .Views(v => { v.DayView(); v.WeekView(); v.CustomView("TwoWeekView"); }) .Group(g => { g.Resources("Labour"); g.Date(true); }) .Resources(resources => resources .Add(m=>m.LabourId) .Name("Labour") .Title("Labour") .DataValueField("Id") .DataTextField("FullName") .DataSource(dataSource => dataSource .Read(read => read .Action("LabourResourcesList", "Scheduler") .Type(HttpVerbs.Post) .Data("LabourResourceSelection") ) .Events(e=>e.Change("RefreshSchedulerView")) ) ) .DataSource(dataSource => dataSource .Read(read => read .Action("ScheduledEvents", "Scheduler") .Type(HttpVerbs.Post) .Data("LabourResourceSelection") ) .Update("UpdateSchedule","Scheduler") .Model(m => { m.Field(f => f.Id); m.Field(f => f.LabourId); m.Field(f => f.Start); m.Field(f => f.End); m.Field(f => f.Description); m.Field(f => f.JobCode); m.Field(f => f.Title); }) .Custom() .Type("aspnetmvc-ajax") .Schema(schema => schema.Model(model => { model.Id(f => f.Id); model.Field(f => f.LabourId); model.Field("title", typeof(string)).From("Description"); model.Field("start", typeof(DateTime)).From("Start"); model.Field("end", typeof(DateTime)).From("End"); model.Field("description", typeof(string)).From("Description"); model.Field("LabourId", typeof(int)).From("LabourId"); }) ) .Events(e => e.RequestEnd("ValidationChecker")) ) .AllDaySlot(false) .AutoBind(false) )So as you can see I am grouping by "Labour",and each event has a corresponding "LabourId".
Updates are sent to the UpdateSchedule action in the SchedulerController, and I have added some server-side validation there to prevent each Labour resource having overlapping events. If all is well I return a null, and the scheduler does what it wants, if there is an overlap I return a JSON with some data to explain that the change is not possible. In the scheduler datasource you can see on the RequestEnd event I call a function "ValidationChecker", which checks the response data, and when the UpdateSchedule action indicates the change cannot be made, I do the following:
var scheduler = $("#Scheduler").data("kendoScheduler"); scheduler.dataSource.cancelChanges(); e.preventDefault();This works, but it only works once consecutively. If I overlap two events, the change is rejected by the validation, and the event that was moved is snapped back to its original place. I can move it around some more and try again, and it will fail again. If two updates fail in a row, the event disappears entirely. I am not sure what is happening here.
Is there a correct way to cancel an update?
...also is there a way to specify a title for a custom view in the MVC scheduler?

Dear Telerik-team,
in my application, I am using the Kendo Map widget and bind it to a view model. Therefore, I followed this example:
http://docs.telerik.com/aspnet-mvc/helpers/map/how-to/bind-map-to-model
Works, the data coming from the database is displayed on the map as markers. That is the HTML code:
@(Html.Kendo().Map()
.Name(Model.Name)
.Center(Model.CenterLatitude, Model.CenterLongitude)
.Zoom(Model.Zoom)
.Layers(layers => layers
.Add()
.Type(MapLayerType.Tile)
.UrlTemplate(Model.TileUrlTemplate)
.Subdomains(Model.TileSubdomains)
.Attribution(Model.TileAttribution)
)
.Markers(markers =>
{
foreach (var marker in Model.Markers)
{
markers.Add()
.Location(marker.latlng)
.Title(marker.name);
}
})
.Events(events => events
.MarkerClick("onMarkerClick"))
)
I want to redirect to a controller action when a user clicks on a marker. Ideally by passing an ID to that controller action in order to fetch the corresponding data of the item from the database. Is there a way to attach the ID of the item, the markers represent, to the marker (like it is possible to specify a title e.g.)?
And how would in this case look the javascript method whichs would call the controller action?
I tried to display the name of the marker with the following javascript:
<script>
function onMarkerClick(e) {
var dataItem = e.sender.marker.dataItem;
alert(dataItem.name)
}
</script>
But this doesn't work :-/
Happy to hear from you,
best regards,
Marco