Hi there
I am looking at using the scheduler. I have a basic CRUD set up with it able to load data from the backend.
Currently the popup includes some fields I don't want (the "Repeat field"). I also want to add some additional fields to it.
Is it possible to customise the fields that appear within the popup. If I add "references" in the .net core they appear as dropdown or multi selects. But I have not found a way to specify what else should be visble/invisible.
I have a model that inherits from ISchedulerEvent
e.g
public class EventsSchedulerViewModel : ISchedulerEvent
{
public EventsSchedulerViewModel()
{
}
public EventsSchedulerViewModel(
long eventId,
string title,
string description,
bool isAllday,
string startTimeZone,
string endTimeZone,
string recurrenceRule,
string recurrenceException,
DateTime startDate,
DateTime endDate,
IEnumerable<int> events)
{
EventId = eventId;
Title = title;
Description = description;
IsAllDay = isAllday;
StartTimezone = startTimeZone;
EndTimezone = endTimeZone;
RecurrenceRule = recurrenceRule;
RecurrenceException = recurrenceException;
Start = startDate;
End = endDate;
Events = events;
}
public long EventId { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public bool IsAllDay { get; set; }
public string StartTimezone { get; set; }
public string EndTimezone { get; set; }
public string RecurrenceRule { get; set; }
public string RecurrenceException { get; set; }
public bool NewField { get; set; } //New field to try and add a tick box to the popup
private DateTime start;
public DateTime Start
{
get
{
return start;
}
set
{
start = value.ToUniversalTime();
}
}
private DateTime end;
public DateTime End
{
get
{
return end;
}
set
{
end = value.ToUniversalTime();
}
}
public IEnumerable<int> Events { get; set; }
}
My guess is either there is some kind of attribute on the model to tell it to populate in the popup.
Or there is some kind of template I can use to then call on the RazorPage?
I was guessing adding a script for a template like:
<script id="event-template" type="text/x-kendo-template">
<div class="k-edit-label"><label for="title">Title</label></div>
<div data-container-for="title" class="k-edit-field">
<input type="text" class="k-textbox" name="title" required="required" data-bind="value:title">
</div>
</script>
and then in the razor doing something like
.EventTemplateId("event-template")
Here is my View:
@inject Microsoft.AspNetCore.Antiforgery.IAntiforgery Xsrf
@Html.AntiForgeryToken()
@(Html.Kendo().Scheduler<FrameWow.Models.Events.Scheduler.EventsSchedulerViewModel>
()
.Name("scheduler")
.Date(DateTime.Today.Date)
.StartTime(DateTime.Today)
.ShowWorkHours(false)
.Height(600)
.Views(views =>
{
views.DayView();
views.WeekView(weekView => weekView.Selected(true));
views.MonthView();
views.AgendaView();
views.TimelineView();
})
.Timezone("Etc/UTC")
.Resources(resource =>
{
resource.Add(m => m.EventId)
.Title("Events")
.DataTextField("Text")
.DataValueField("Value")
.DataColorField("Color")
.BindTo(new[]
{
new { Text = "Room 1", Value = 1, Color = "#6eb3fa" },
new { Text = "Room2", Value = 2, Color = "#f58a8a" }
});
resource.Add(m => m.Events)
.Title("Events")
//.Name("Events")
.Multiple(true)
.DataTextField("Text")
.DataValueField("Value")
.DataColorField("Color")
.BindTo(new[]
{
new { Text = "Meeting 1", Value = 1, Color = "#f8a398" } ,
new { Text = "Meeting 2", Value = 2, Color = "#51a0ed" } ,
new { Text = "Meeting 3", Value = 3, Color = "#56ca85" }
});
})
//.EventTemplateId("event-template")
.DataSource(d => d
.Model(m =>
{
m.Id(f => f.EventId);
m.Field(f => f.Title).DefaultValue("No title");
m.Field(f => f.Events).DefaultValue(1);
})
.Read(read => read.Url(Url.Page("Scheduler","ReadEventScheduler")).Data("additionalData").Type(HttpVerbs.Post))
.Create(create => create.Url(Url.Page("Scheduler","CreateEventScheduler")).Data("additionalData").Type(HttpVerbs.Post))
.Update(update => update.Url(Url.Page("Scheduler","UpdateEventScheduler")).Data("additionalData").Type(HttpVerbs.Post))
.Destroy(destroy => destroy.Url(Url.Page("Scheduler","DeleteEventScheduler")).Data("additionalData").Type(HttpVerbs.Post))
)
)
I want to hide the "recurring" items and selection from the popup and add some of my own fields in. I have had a look at the documentation around templates and couldn't find anything suggesting how to do this.
Any help to point me in the right direction would be appreciated.
Thanks
I have a grid with an object as a column. For example, let's say we have column.Bound(b => b.Product), where Product is an object of { Id: int, Name: string }. I also use an editor template dropdrownlist which has the same model so it binds properly, so just having Product.Name bound to the column wouldn't seem to work well in this case.
Is there a way to make it so that the filters just take in the value of Product.Name? I saw others with similar issues online, but didn't see a solution that worked for me.
Hi,
Based on this checkboxes DropDownTree demo, is it possible to display only the checked parent node, say Kendo UI Project on the tagList but still have its children checked? Basically, when I check the Kendo UI Project node, I also want its children checked, but only display the "Kendo UI Project" on the tagList.
Thanks!
I use a ColorPicker in an EditorTemplate of an object edited via Popup of the Grid.
When Editing, it displays the Color of the edited object, that is OK. However, when an object is created, the ColorPicker should display, by default, a random color.
How to detect, in the EditorTemplate, that the object is created, and generate a random color?
<div class="form-group">
<label asp-for="Couleur" class="control-label"></label>
@(Html.Kendo()
.ColorPicker()
.Name("Couleur")
.Value("#ff0000") //"# (0) ? 'yellow' : 'red'#" does not help, it displays black anyway!!!!
.Messages(b => b
.Apply("Appliquer")
.Cancel("Annuler")
.PreviewInput("Prévisualiser"))
)
<span asp-validation-for="Couleur" class="text-danger"></span>
</div>
In a kendo grid with popup edition, I have the EditTemplate for my DTO object.
When I click on "+Add" grid button I will have the popup with the title "Edit" and if I click on "/Edit", I will have the same popup, with same title.
1) Is there a way to change the popup title in "Add" when I add the object, and "Edit" if I edit it?
2) More than that, I need to "readonly" the DropDown in "edit" mode, and enable it in "add" mode. How to achieve it?
Knowing that the Model in the EditorTemplate is always null, there is any way to do verifications on the server Model...
3) When I add new object, I have a logic to prepare the DTO, before displaying it to the user. However, I have only the method that
[AcceptVerbs("Post")]
public ActionResult ByOneCreate([DataSourceRequest] DataSourceRequest request, MyDTO dto)
is there a way to use a method like this, to pre-fill the initially created object:
[AcceptVerbs("Get")]
public ActionResult ByOneCreate([DataSourceRequest] DataSourceRequest request)
in the HtmlAttributes , of a TextBox, or DrowDownList etc it seems there is no way to put readonly to false, at least, there is any effect: the field remains always readonly, once the readonly attribute is present, even if is readonly = false;
@(Html.Kendo().TextBoxFor(m=>m.ToitTN).HtmlAttributes(new { @readonly = false }))
DropDownList readonly property keeps control readonly when readonly=false
Html.Kendo().DropDownList() .Name("LayerId") .HtmlAttributes(new { style = "width:100%;background:#:data.Color#;", @readonly = false })
More than that, if this code is in an EditorTemplate of a Model edited in a grid, there is no way to put readonly property using Model in the view.
Model is always null... @readonly = (Model.SomethingId > 0) throws an error, because Model is null when initialising the Grid
Hi,
I'm stuck trying to return a DataSourceResult from an API and deserialize it using JSONConvert.DeserializeObject<DataSourceResult>(json)
This is what I am doing on the ASP.NET Core API side using a DataSourceRequest as input.
DataSourceResult result = await _repo.Internments.ToDataSourceResultAsync(dsRequest);
return new ContentResult() {
StatusCode = StatusCodes.Status200OK,
ContentType = "application/json",
Content = JsonConvert.SerializeObject(result, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All })
};
Then I am trying to deserialize it on the receiving end (HttpResponseMessage) in an ASP.NET Core MVC controller for use in a grid:
string funcJSON = getResponse.Content.ReadAsStringAsync().Result;
result = JsonConvert.DeserializeObject<DataSourceResult>(funcJSON, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All } );
An exception is generated when I try to deserialize it. The assembly is there. Not sure what I am doing wrong.
"Error resolving type specified in JSON 'Telerik.DataSource.DataSourceResult, Telerik.DataSource'. Path '$type', line 1, position 66."
Any help is appreciated. Thanks!
html-helper work correct, but tag-helper does not work, 2021R1
my code as follow:
@{
ViewData["Title"] = "UserManager";
Layout = "~/Pages/_Layout.cshtml";
IEnumerable<ComboBoxItemBase> listDept = Model.ds.Osdept.OrderBy(q => q.Deptname).Select(q=> new ComboBoxItemBase() { Id=q.Id, Text=q.Deptname }).ToList().AsEnumerable();
}
<kendo-grid name="DgUser" resizable="true"
selectable="true" style="height:calc(100vh - 270px)"
navigatable="true" on-edit="DgUserEdit">
<filterable enabled="false" />
<sortable enabled="true" />
<editable enabled="true" />
<columns>
<foreign-key-column title="department" field="DeptId" values='@listDept' value-field="Id" text-field="Text" width="150" >
</foreign-key-column>
</columns>
</kendo-grid>
@(Html.Kendo().Grid<Models.AspNetUsers>()
[HttpPost]
public JsonResult Create([DataSourceRequest] DataSourceRequest request, License license)
{
var x= LicenseRepository.produect.ID==license.productId && LicenseRepository.vendorID==license.VendorId.any();
}
@model KendoUIMVC5.Models.License
<script type="text/javascript">
function filterVendors() {
return {
customerId: $("#CustomerId").data("kendoDropDownList").value()
};
}
function filterProducts() {
return {
vendorId: $("#VendorId").data("kendoDropDownList").value()
};
}
</script>
<fieldset>
<legend>Cascading DropDownLists:</legend>
<dl>
<dt>
@Html.LabelFor(m => m.CustomerId):
</dt>
<dd>
@(Html.Kendo().DropDownListFor(m => m.CustomerId)
.ValuePrimitive(true)
.OptionLabel("Select Customer...")
.DataTextField("CustomerName")
.DataValueField("CustomerId")
.DataSource(dataSource =>
{
dataSource.Read(read => read.Action("GetCustomers", "Home"))
.ServerFiltering(true);
})
)
@Html.ValidationMessageFor(m => m.CustomerId)
</dd>
</dl>
<dl>
<dt>
@Html.LabelFor(m => m.VendorId):
</dt>
<dd>
@(Html.Kendo().DropDownListFor(m => m.VendorId)
.AutoBind(false)
.ValuePrimitive(true)
.OptionLabel("Select Vendor...")
.DataTextField("VendorName")
.DataValueField("VendorId")
.DataSource(dataSource =>
{
dataSource.Read(read => read.Action("GetVendors", "Home").Data("filterVendors"))
.ServerFiltering(true);
})
.CascadeFrom("CustomerId")
)
@Html.ValidationMessageFor(m => m.VendorId)
</dd>
</dl>
<dl>
<dt>
@Html.LabelFor(m => m.ProductId):
</dt>
<dd>
@(Html.Kendo().DropDownListFor(m => m.ProductId)
.AutoBind(false)
.ValuePrimitive(true)
.OptionLabel("Select Product...")
.DataTextField("ProductName")
.DataValueField("ProductId")
.DataSource(dataSource =>
{
dataSource.Read(read => read.Action("GetProducts", "Home").Data("filterProducts"))
.ServerFiltering(true);
})
.CascadeFrom("VendorId")
)
@Html.ValidationMessageFor(m => m.ProductId)
</dd>
</dl>
</fieldset>