I have a Telerik MVC Grid in a Razor view. I have added the ColumnMenu option which gives the user the ability to show/hide columns in the grid. By default it places this in the context menu of the header of the columns. I want to change this so that it is available in the ToolBar header as a custom control.
@(Html.Kendo().Grid<StockReport>()
.Name("grid")
.Columns(columns =>
columns.Bound(p => p.SohQty).Title("Quantity");
columns.Bound(p => p.StockName).Title("Item Name");
...
.ToolBar(tools => tools.Excel())
.ToolBar(tools => tools.Custom()
.Text("Customise")
.WhatToPutHere?????
)
.ColumnMenu() //I want to reuse this but in the custom toolbar
I think it sits better in the toolbar header since it is about all the columns whereas the rest of the items in the context header of a column relate to just that column (filtering, sorting).
The only thing I don't know is what I can put on the custom toolbar in order to make use of the existing ColumnMenu control
I generate an html report by replacing the keys in the html file with dynamic values. When converting to a pdf file using Telerik this error is thrown. I have checked several times and I do not have any duplicated keys. The error is thrown when trying to import the html report.
JpegImageConverterBase customJpegImageConverter = new CustomJpegImageConverter();
Hi Team,
I am facing issue in ClientDetailTemplateId Grid when using checkbox, data coming from database is true checkbox selected but if we checkbox checked or uncheck then checkbox values not sending proper values in jquery bellow sending code for grid.
@(
Html.Kendo().Grid<PNWorklistSupplierGridViewModel>()
.Name("pnwlGrid_#=Id#") // template expression, to be evaluated in the master context
.Columns(columns =>
{
columns.Command(command =>
{
command.Custom("editPn1").Text(" ").IconClass("k-icon k-i-pencil").Click("OpenSupplierEditWindowPN");
}).Width(40).HtmlAttributes(new { @style = "text-align: center;" });
columns.Bound(e => e.Check).Title("test").Width(150)
.ClientTemplate("<input type='checkbox' \\#=Check? checked='checked' : '' \\# />")
.HeaderHtmlAttributes(new { @class = "headerText" }).Sortable(false).Filterable(false).HtmlAttributes(new { @style = "text-align: center;" });
If Check checkbox checked then js file getting Check values false
please check and let me know any thing else required.
Thank you!
I am new to the kendo UI, i have followed the demo for scheduler in ASP.NET MVC and added all the code but I am stuck here.
I have added the nuget and controller and model but I am stuck at ui side, it not showing scheduler.
Console errors
below is my code.
Index.cshtml :
@using Kendo.Mvc.UI
<div id="team-schedule">
<div id="people">
<input checked type="checkbox" id="alex" aria-label="Alex" value="1">
<input checked type="checkbox" id="bob" aria-label="Bob" value="2">
<input type="checkbox" id="charlie" aria-label="Charlie" value="3">
</div>
</div>
@(Html.Kendo().Scheduler<Anics.FrontEnd.Models.Scheduler.TaskViewModel>()
.Name("scheduler")
.Date(new DateTime(2022, 6, 13))
.StartTime(new DateTime(2022, 6, 13, 7, 00, 00))
.Height(600)
.Views(views =>
{
views.DayView();
views.WorkWeekView(workWeekView => workWeekView.Selected(true));
views.WeekView();
views.MonthView();
views.YearView();
views.AgendaView();
views.TimelineView();
})
.Timezone("Etc/UTC")
.Resources(resource =>
{
resource.Add(m => m.OwnerID)
.Title("Owner")
.DataTextField("Text")
.DataValueField("Value")
.DataColorField("Color")
.BindTo(new[] {
new { Text = "Alex", Value = 1, Color = "#f8a398" } ,
new { Text = "Bob", Value = 2, Color = "#51a0ed" } ,
new { Text = "Charlie", Value = 3, Color = "#56ca85" }
});
})
.DataSource(d => d
.Model(m => {
m.Id(f => f.TaskID);
m.Field(f => f.Title).DefaultValue("No title");
m.Field(f => f.OwnerID).DefaultValue(1);
m.RecurrenceId(f => f.RecurrenceID);
})
.Read("Basic_Usage_Read", "Scheduler")
.Create("Basic_Usage_Create", "Scheduler")
.Destroy("Basic_Usage_Destroy", "Scheduler")
.Update("Basic_Usage_Update", "Scheduler")
.Filter(filters =>
{
filters.Add(model => model.OwnerID).IsEqualTo(1).Or().IsEqualTo(2);
})
)
)
@*<script type="text/javascript">
$(document).ready( function () {
$("#people :checkbox").change(function (e) {
var checked = $.map($("#people :checked"), function (checkbox) {
return parseInt($(checkbox).val());
});
var filter = {
logic: "or",
filters: $.map(checked, function (value) {
return {
operator: "eq",
field: "OwnerID",
value: value
};
})
};
var scheduler = $("#scheduler").data("kendoScheduler");
scheduler.dataSource.filter(filter);
});
})
</script>*@
<style>
#team-schedule {
background: url('@Url.Content("~/Content/web/scheduler/")team-schedule.png') transparent no-repeat;
height: 115px;
position: relative;
}
#people {
background: url('@Url.Content("~/Content/web/scheduler/")scheduler-people.png') no-repeat;
width: 345px;
height: 115px;
position: absolute;
right: 0;
}
#alex {
position: absolute;
left: 4px;
top: 81px;
}
#bob {
position: absolute;
left: 119px;
top: 81px;
}
#charlie {
position: absolute;
left: 234px;
top: 81px;
}
</style>
I would like to display data in a popup window or tooltip when users hover over or click on a cell in the Telerik grid. I tried using the Telerik tooltip, however the tooltip doesn't display at all. I also tried the jquery and bootstrap tooltips, but they do not work as well. When I use the tooltips for an element outside of the grid, they work fine. Does anyone have a razor example for using the Telerik tooltip in a grid? Also, are there other ways to approach this? Essentially, I want to display a small popup window with a table of additional information related to one specific cell in each row of the table.
I have a chart that tracks website registrations by date, Country and State. A user selects which country(ies) and state(s) they want to see and the chart should have a column for each country for each date (aggregate by year)
My current View code:
@(Html.Kendo().Chart<DatePoint>()
.Name("RegistrationDashboard")
.Title("Total Registrations")
.Theme("material")
.DataSource(ds => ds
.Read(read => read.Action("RegistrationDashboard_Read", "Reports").Data("filterReport"))
.Group(group =>
group.Add(grp => grp.Country)
)
)
.Series(series =>
{
series.Column(model => model.Value, categoryExpression: model => model.Date).Aggregate(ChartSeriesAggregate.Count).Stack("Country").Name("");
})
.CategoryAxis(axis =>
axis
.Date()
.BaseUnit(ChartAxisBaseUnit.Years)
.MajorGridLines(lines => lines.Visible(false))
)
.ValueAxis(axis => axis
.Numeric()
.Line(line => line.Visible(false))
)
.Tooltip(tooltip => tooltip.Visible(true))
)
An example of JSON data sent from the datasource (I have a button that refreshes the data source whenever a user chooses new countries/states)
[
{
"Date": "/Date(1558584000000)/",
"Value": 1,
"Country": "Colombia",
"State": "Cundinamarca"
},
{
"Date": "/Date(1562299200000)/",
"Value": 1,
"Country": "Bolivia",
"State": "Santa Cruz"
},
{
"Date": "/Date(1572494400000)/",
"Value": 1,
"Country": "Colombia",
"State": "Antioquia"
},
{
"Date": "/Date(1580533200000)/",
"Value": 1,
"Country": "Mexico",
"State": "Estado de Mexico"
},
{
"Date": "/Date(1585281600000)/",
"Value": 1,
"Country": "Bolivia",
"State": "Beni"
},
{
"Date": "/Date(1594094400000)/",
"Value": 1,
"Country": "Bolivia",
"State": "Santa Cruz"
},
{
"Date": "/Date(1594094400000)/",
"Value": 1,
"Country": "Bolivia",
"State": "Santa Cruz"
},
{
"Date": "/Date(1594094400000)/",
"Value": 1,
"Country": "Bolivia",
"State": "Santa Cruz"
},
{
"Date": "/Date(1594094400000)/",
"Value": 1,
"Country": "Bolivia",
"State": "Santa Cruz"
},
{
"Date": "/Date(1607058000000)/",
"Value": 1,
"Country": "Colombia",
"State": "Antioquia"
},
{
"Date": "/Date(1608008400000)/",
"Value": 1,
"Country": "Mexico",
"State": "Jalisco"
},
{
"Date": "/Date(1608008400000)/",
"Value": 1,
"Country": "Mexico",
"State": "Jalisco"
},
{
"Date": "/Date(1608526800000)/",
"Value": 1,
"Country": "Colombia",
"State": "Antioquia"
},
{
"Date": "/Date(1626148800000)/",
"Value": 1,
"Country": "Mexico",
"State": "Queretaro"
},
{
"Date": "/Date(1632801600000)/",
"Value": 1,
"Country": "Bolivia",
"State": "Santa Cruz"
},
{
"Date": "/Date(1633924800000)/",
"Value": 1,
"Country": "Colombia",
"State": "Valle del Cauca"
},
{
"Date": "/Date(1634011200000)/",
"Value": 1,
"Country": "Colombia",
"State": "Antioquia"
},
{
"Date": "/Date(1640840400000)/",
"Value": 1,
"Country": "Mexico",
"State": "Aguascalientes"
},
{
"Date": "/Date(1641445200000)/",
"Value": 1,
"Country": "Mexico",
"State": "Aguascalientes"
},
{
"Date": "/Date(1642741200000)/",
"Value": 1,
"Country": "Mexico",
"State": "Aguascalientes"
},
{
"Date": "/Date(1643691600000)/",
"Value": 1,
"Country": "Mexico",
"State": "Mexico"
},
{
"Date": "/Date(1650340800000)/",
"Value": 1,
"Country": "Bolivia",
"State": "Santa Cruz"
},
{
"Date": "/Date(1650340800000)/",
"Value": 1,
"Country": "Bolivia",
"State": "Santa Cruz"
},
{
"Date": "/Date(1652241600000)/",
"Value": 1,
"Country": "Bolivia",
"State": "Cochabamba"
},
{
"Date": "/Date(1652328000000)/",
"Value": 1,
"Country": "Bolivia",
"State": "Cochabamba"
},
{
"Date": "/Date(1661140800000)/",
"Value": 1,
"Country": "Colombia",
"State": "Bogota"
},
{
"Date": "/Date(1664856000000)/",
"Value": 1,
"Country": "Colombia",
"State": "Narino"
}
]
I would like to have a series column for each country for each year. Each column would be stacked based on the number of registrations per state.
The user could choose from 1...N countries. (I'm sure I can set a limit so the chart isn't out of control, but that's not the point)
When I set the datasource group to "State", there is a series column for each year and the legend shows each state. When I group by "Country", there is only 1 series column for each year and the legend shows the countries selected. I have included a screenshot of each grouping
How do I make a series column for each country with the amounts "stacked" for that country's respective states?
Hi, im currently creating a Grid with dynamic columns and came across with this post and current following the structure.
Dynamic Data in the Kendo UI Grid (telerik.com)
My problem is that during Update, I cant seem to access the Property Values of those edited columns.
Can I get the actual code for the "Update" of this demo API?
https://demos.telerik.com/kendo-ui/service/products/Update
Heres my update code btw:
[HttpPost]
public JsonResult Update_Employee([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<dynamic> models)
{
foreach(var obj in models)
{
string a = GetProperty(obj, "EmployeeName");
}
return Json(ModelState.ToDataSourceResult());
}
private object GetProperty(dynamic obj, string propertyName)
{
var objDict = obj as IDictionary<string, object>;
if (objDict.ContainsKey(propertyName))
{
var value = objDict[propertyName];
if (value != null)
return value;
}
return null;
}
Hi All,
We're using telerik kendo treelist for the application. we need functionality like if we click on Copy data button then it will clone the selected row along with data. We've tried to find copy functionality but we're not able to do it. so we have add custom button ("Copy Data").
Please let us know if there is any other way to achieve this functionality.
adding button "Copy Data" in toolbar:
.Toolbar(tb =>
{
tb.Custom().Name("Copy").Text("Copy Data");
})
"Copy Data" button click event:
$('.k-button-text').click(function () {
alert('clicked');
debugger
var treeList = $("#TeamTreeList").data("kendoTreeList");
var row = treeList.select();
if (row.length > 0) {
var data = treeList.dataItem(row);
console.log(data.RoleName);
}
});
I have an ASP.NET MVC project, using Kendo MVC 2023 R1, and I am using a strict CSP policy. However, the following code is not working
<add name="Content-Security-Policy" value="script-src 'self'
Index.Cshml
<script id="editor-template" type="text/x-kendo-template">
@Html.Kendo().TextBox().Name("FieldExcel").Enable(false).ToClientTemplate()
</script>
in JS
$(document).ready(() => {
$(".list-item-icon").on("click", e => {
$("#edit-dialog").kendoWindow({
height: 320,
width: 415,
title: 'Editar',
visible: false
});
var thtml = $("#editor-template").html();
var htmlEncode = kendo.htmlEncode;
var templateString = () => thtml;
var template = kendo.template(templateString);
var data = { firstName: "Todd", age: 16 };
var result = template(data);
//var template = kendo.template($("#editor-template").html());
$("#edit-dialog").data("kendoWindow").content(template({})).open().center();
The result is a simple input text instead of a disabled Kendo control.
I have been trying many ways, and I can't find a solutionI have a model class given below in MVC. I am trying to set MinDate and MaxDate for the DatePicker
public class YourModel { public DateTime Deadline { get; set; } public DateTime MinDate { get; set; } public DateTime MaxDate { get; set; } }
@(Html.Kendo().DatePickerFor(x => x.Deadline) .Name("datepicker") // Set the name attribute .Format("MM/dd/yyyy") .Min(DateTime.Today) // Set the minimum date .Max(DateTime.Today.AddMonths(3)) // Set the maximum date (in this example, 3 months from today) .HtmlAttributes(new { id = "datepicker" }) // Set the ID attribute )