Question
I had a grid with EditMode of "GridEditMode.InCell".
Users can insert multiple data by Datasource ajax create method.
The create method works fine the first time.
However, when I tried to insert data the second time
The action recieved all of the data from view(includes the data already inserted in the first time).
How I can prevent from getting datas already inserted?
Is there any work arrounds?
@(Html.Kendo().Grid<Digitalization2.Web.Controllers.AgentOrder.CreateOrderDetailViewModel>()
.Name("agentordergrid")
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.Batch(true)
.Model(model =>{
model.Id(x => x.ID);
model.Field(x => x.ID).Editable(false);
model.Field(x => x.ProductTypeView).DefaultValue(new ProductTypeViewModel(){ ParameterValue = "SD"});
model.Field(x => x.ProductModelView).DefaultValue(new ProductModelViewModel(){ProductID = 1, ProductModel = "SSD0100"});
})
.Read(read => read.Action("GetOrderDetailByOrderId", "AgentOrder", new { agentOrderId = @data.ID}))
.Create(create => create.Action("CreateAgentOrderDetail", "AgentOrder"))
.Destroy(destroy => destroy.Action("DeleteAgentOrdetDetails", "AgentOrder"))
)
.Columns(col => {
col.Bound(x => x.ProductTypeView).Width(150).ClientTemplate("#=ProductTypeView.ParameterValue#");
col.Bound(x => x.ProductModelView).Width(250).ClientTemplate("#=ProductModelView.ProductModel#");
col.Bound(x => x.ItemCount).Width(75);
col.Bound(x => x.UnitPrice).Width(150);
col.Bound(x => x.Remark).Width(500);
col.Command(command => command.Destroy()).Width(75);
})
.ToolBar(toolbar =>
{
toolbar.Create();
toolbar.Save().;
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
)
I have a datepicker databound to a model as follows:
<div class="col-sm-3">
<label asp-for="ADR.Date" class="form-label"></label>
<kendo-datepicker for="ADR.Date" class="form-control"></kendo-datepicker>
<span asp-validation-for="ADR.Date" class="text-danger"></span>
</div>
The ADR model property does not allow nulls:
[DataType(DataType.Date)]
public DateTime Date { get; set; }
This is for good reason, I want to prevent the user from omitting the date when they fill out the form and for the data validation to fire correctly.
However instead of being empty when the form is first opened, the Datepicker fills the date with 01/01/1901, which is unwanted behavior as the user then doesn't enter a correct date.
How do we ensure the datepicker is empty when first loading the form and the calendar is on todays date when empty?
How do I display text in a grid row conditionally using a row template? I have tried the following variations.
#Sex == 1 ? Male : Female#
#Sex == 1 ? \"Male\" : \"Female\"#
#Sex == 1 ? <span>Male</span> : <span>Female</span>#
Here is the row template definition:
.ClientRowTemplate(
"<tr data-uid='#: uid #' class='k-master-row p-2 m-2'>" +
"<td class='k-hierarchy-cell k-table-td' aria-expanded='false' role='gridcell' style='max-width:40px;'>" +
"<a href='\\#' aria-label='Expand' tabindex='-1' class='k-icon k-i-caret-alt-right'></a>" +
"</td>" +
"<td class='defendantDetails col-sm-12 col-md-10'>" +
// THIS IS THE PROBLEMATIC SPOT
"<div class='d-inline-block'>#Sex == 1 ? <span>Male</span> : <span>Female</span># - #=Race# - SSN: #=Ssn# - DOB: #=Dob#</div>" +
"</div>" +
"<div class='d-inline-block ms-auto'>" +
"<button type='button' class='ms-auto k-grid-edit-command k-button k-button-md k-rounded-md k-button-solid k-button-solid-primary'>" +
"<span class='k-svg-icon k-svg-i-pencil k-button-icon' aria-hidden='true'>" +
"<svg viewBox='0 0 512 512' focusable='false' xmlns='http://www.w3.org/2000/svg'>" +
"<path d='m334.9 86.6 45.3-45.3c12.4-12.4 32.8-12.4 45.3 0l45.3 45.3c12.4 12.4 12.4 32.8 0 45.3l-45.3 45.3-90.6-90.6zm-22.6 22.6L32 389.5V480h90.5l280.3-280.3-90.5-90.5zM99.9 412.1l-22.6-22.6 235-235 22.6 22.6-235 235z'></path>" +
"</svg>" +
"</span>" +
"<span class='k-button-text'>Edit</span>" +
"</button>" +
"<button type='button' class='k-grid-remove-command k-button k-button-md k-rounded-md k-button-solid k-button-solid-base'>" +
"<span class='k-svg-icon k-svg-i-x k-button-icon' aria-hidden='true'>" +
"<svg viewBox='0 0 512 512' focusable='false' xmlns='http://www.w3.org/2000/svg'>" +
"<path d='M416 141.3 301.3 256 416 370.7 370.7 416 256 301.3 141.3 416 96 370.7 210.7 256 96 141.3 141.3 96 256 210.7 370.7 96l45.3 45.3z'></path>" +
"</svg>" +
"</span>" +
"<span class='k-button-text'>Delete</span>" +
"</button>" +
"</div>" +
"</td>" +
"</tr>"
)
I have come across scenario that I will have to hide a dropdownlist but need to send the selected value on postback.
Could some one help me with this.
Below is the sample code I am using to load the dropdownlist
@{I had a look at the ISchedulerEvent inside the Kendo.MVC.UI namespace and found that it's using predefined binding for column names such as Title, Description, Start, End, etc.
However, I have a data controller and model that has some of those, but I have many other data columns that I need mapped to a Telerik Scheduler-Timeline control.
Is it possible to edit the ISchedulerEvent to allow other columns? I have data that eventually I will need to show up in the Scheduler as a tooltip (custom javascript I can see already here, but very little documentation on how in your website). And how do I customise the CSS too please? I want to change the way the MonthView displays data, down to 12hr blocks per day for a max of 7 days in the one screen.
Also, I noticed the following errors/messages when viewing the control source code:
namespace Kendo.Mvc.UI
{
public interface ISchedulerEvent
{
string Title { get; set; }
string Description { get; set; }
bool IsAllDay { get; set; }
DateTime Start { get; set; }
DateTime End { get; set; }
string StartTimezone { get; set; }
string EndTimezone { get; set; }
string RecurrenceRule { get; set; }
string RecurrenceException { get; set; }
}
}
#if false // Decompilation log
'325' items in cache
------------------
Resolve: 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
Found single assembly: 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
Load from: 'C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\7.0.5\ref\net7.0\System.Runtime.dll'
------------------
Resolve: 'Microsoft.AspNetCore.Mvc.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
Found single assembly: 'Microsoft.AspNetCore.Mvc.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
Load from: 'C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\7.0.5\ref\net7.0\Microsoft.AspNetCore.Mvc.Abstractions.dll'
What does this mean? I am using .Net 6 not .Net 7.
Obviously, I am new to ASP.Net Core but I am familiar with the EntityFramework to get data from a SQL Server database. I know that part of my project is working, but I am having a hard time understanding the ISchedulerEvent and why I have to use it, and how to use it to customise my data mappings.
Please don't offer me the Scheduler getting-started-scheduler page. I've done all that and it's very thin on explaining how things are working, and besides the model in the example is purely limited to the existing columns in the ISchedulerEvent .
Thanks
Hello,
I am new to Kendo grid. I would like to add a textarea for inline editing of a grid field. Currently in edit mode there is a text box and I want to replace this with a multi line textarea. My grid is using Ajax.
thanks.
Hi,
Is there a way to position the buttons so that the clock button comes after the calendar?This is more logical as the ISO date format used in our application.
While scanning our projects for security vulnerabilites, we noticed that Telerik.UI.for.AspNet.Core 2023.2.606 references an of .NET Core 2.1 which is 5 years old and long since unsupported? This means that using Telerik.UI.for.AspNet.Core immediately introduces the critical security vulnerabilies present in .NET Core 2.1. Why does it depend on this ancient version of .NET?
Here is a new completely empty project created just now (July 2023!) and you can see the references to .NET Core 2.1:
And here's a resulting security scan of this empty project:
Is .NET Core still supported by Telerik because it seems odd this hasn't been fixed in 5 years.