In one of our projects, we are using Kendo UI Q2 and we cannot upgrade because of IE8 support and we need Export to Excel & Export to PDF features. So we decided to take these features to server side.
By googling, I found following sample projects from github:
https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/grid/excel-export-server-side
https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/grid/pdf-export-server-side
These seem to be helping but in the PDF part I see that iTextSharp is used and it's commercial license is NOT FREE. What I want to confirm is that by having a valid license of Telerik DevCraft, can we use iTextSharp commercially or do we need separate license for it?
Any other help or solution will be highly appreciated.
@(Html.Kendo().ComboBox()
.Name("fabric")
.Filter("contains")
.Placeholder("Select fabric...")
.DataTextField("Text")
.DataValueField("Value")
.DataSource(source =>
source.Read(read =>
{
read.Url("http://localhost:59590/api/Search/LoadonDemand");
}).ServerFiltering(true))
.HighlightFirst(true)
.IgnoreCase(true)
Is it possible to mask a phone number with or without an extension? I'm looking for:
(612) 555-1212
or
(612) 555-1212 ext. 5
or
(612) 555-1212 ask for Larry
Basically, the beginning of the string must be formatted as a phone number, but the user can enter whatever they want after that.
Can I do it?
Thanks!
I have a dynamic model below is the cshtml code, is line editing possible with dynamic model ?
@(Html.Kendo().Grid<dynamic>()
.Name(
"requestCapacity"
)
.Columns(columns =>
{
foreach
(var c
in
Model)
{
if
(c.Equals(
"Week Starting"
))
columns.Template(@<text> </text>).ClientTemplate(@
"<span class='k-widget k-datepicker' style='width: 150px;'><span class='k-picker-wrap k-state-default'><input id='datepicker' style='width: 100%;' data-role='datepicker' type='text' class='k-input' role='combobox' aria-expanded='false' aria-owns='datepicker_dateview' aria-disabled='false' aria-readonly='false' aria-activedescendant='270cfa37-b189-46a8-b0ea-857df06f84ab_cell_selected'><span unselectable='on' class='k-select' role='button' aria-controls='datepicker_dateview'><span unselectable='on' class='k-icon k-i-calendar'>select</span></span></span></span>"
).Width(150).Title(c.Key);
else
columns.Template(@<text>c</text>).Title(c.Key);
}
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
}
)
.Editable(editable => editable.Mode(GridEditMode.PopUp))
.HtmlAttributes(
new
{ style =
"height:auto;width:85%;align:center;margin:0 auto"
})
.Pageable()
.ToolBar(toolbar => toolbar.Create().Text(
"Add"
))
.Sortable()
.Scrollable().EnableCustomBinding(
true
)
.DataSource(dataSource => dataSource
.Ajax().Model(model =>model.Id(
"ID"
)
)
.PageSize(10)
.Events(events => events.Error(
"error_handler"
))
.Create(update => update.Action(
"EditingInline_Update"
,
"RequestCapacity"
,
new
{testing=
"#=dataItem#"
}).Type(HttpVerbs.Post))
.Read(read => read.Action(
"PopulateRequest"
,
"RequestCapacity"
).Type(HttpVerbs.Post))
.Update(update => update.Action(
"EditingInsline_Update"
,
"RequestCapacity"
,
"#=dataItem#"
).Type(HttpVerbs.Post))
.Destroy(update => update.Action(
"EditingInline_Destroy"
,
"Capacity"
))
)
)
controller code.
public
ActionResult RequestCapacityPopUp()<br> {<br> var dynamicBinding =
new
List<
string
>(){
"Week Starting"
};<br>
using
(var dataModel =
new
CapacityPlannerEntities())<br> {<br>
foreach
(var team
in
dataModel.Teams)<br> {<br> dynamicBinding.Add(team.TeamName);<br> }<br> }<br>
return
View(dynamicBinding);<br> }
Hi
How do I pass a value from the button .content
@(Html.Kendo().Button()
.Name("p14")
.HtmlAttributes(new { type = "button" })
.Content("135")
.Events(ev => ev.Click("onClickPol")))
<script>
function onClickPol(e) {
//This dos not work, I want to retrieve the name, content of that button what n this case is 135
var xContent = $(e.event.target).closest(".k-button").attr("textContent")
}
</script>
Strange that I have one grid instance where I created a custom ClientRowTemplate, as I needed to display an image and other info...
I have 2 custom command buttons, one to show Item Details, and another to Copy Item details, basically pointing to distinct jQuery functions that get the id of the record in the row then redirect to a specific controller action.
It seems that regardless of which button is clicked, the first function is being fired...
Here is the grid markup...
@(Html.Kendo().Grid<LibEquipmentApp.ViewModels.SimpleItemViewModel>()
.Name("ManageItems")
.Columns(columns =>
{
columns.Bound(p => p.EItemID).Width(0).Visible(false);
columns.Bound(p => p.ECatID)
.Width(0)
.Visible(false);
columns.Bound(p => p.ImgPath)
.Filterable(false)
.Width(80)
.Title("Photo");
columns.Bound(p => p.EItemName)
.Width(240)
.Title("Item Name");
columns.Bound(p => p.SDBBarcode)
.Width(100)
.Title("Barcode #");
columns.Command(command => { command.Custom("Details").Click("showDetails"); command.Custom("Copy").Click("showCopy"); }).Width(140);
})
.ClientRowTemplate(
"<tr class='k-std' data-imgpath='#: ImgPath #'>" +
"<td >" +
"<img class='img-responsive' src='" + Url.Content("~/Images/EqImg/") + "#:data.ImgPath#' alt='#: data.EItemName #' />" +
"</td>" +
"<td class='details'>" +
"<span class='name'>#: EItemName# </span>" +
"</td>" +
"<td class='details'>" +
"#: SDBBarcode #" +
"</td>" +
"<td class='details'>" +
"<a class='k-button k-button-icontext k-grid-Details'><span>Details</span> </a>" +
"<a class='k-button k-button-icontext k-grid-Details'><span>Copy</span> </a>" +
"</td>" +
"</tr>"
)
.ClientAltRowTemplate(
"<tr class='k-altz' data-imgpath='#: ImgPath #'>" +
"<td >" +
"<img class='img-responsive' src='" + Url.Content("~/Images/EqImg/") + "#:data.ImgPath#' alt='#: data.EItemName #' />" +
"</td>" +
"<td class='details'>" +
"<span class='name'>#: EItemName # </span>" +
"</td>" +
"<td class='details'>" +
"#: SDBBarcode #" +
"</td>" +
"<td class='details'>" +
"<a class='k-button k-button-icontext k-grid-Details'><span>Details</span> </a>" +
"<a class='k-button k-button-icontext k-grid-Details'><span>Copy</span> </a>" +
"</td>" +
"</tr>"
)
.Filterable(filterable => filterable
.Extra(false)
.Operators(operators => operators
.ForString(str => str.Clear()
.StartsWith("Starts with")
.IsEqualTo("Is equal to")
.IsNotEqualTo("Is not equal to")
.Contains("Contains")
))
)
.Pageable()
.Navigatable()
.Sortable()
.Scrollable()
.HtmlAttributes(new { style = "height:600px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Events(events => { events.Error("error_handler"); events.RequestEnd("onRequestEnd"); })
.Model(model =>
{
model.Id(p => p.EItemID);
})
.Read(read => read.Action("Items_Read", "Admin"))
)
)
And here are the functions....
<script type="text/javascript">
function showDetails(e) {
e.preventDefault();
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
var id = dataItem.EItemID;
$.ajax({
url: "/Admin/ManageItem",
//send current record ID to the server
data: { id: dataItem.EItemID },
error: function () {
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);
}
},
success: function (data) {
window.location = '/Admin/ItemDetails?id=' + id;
}
})
}
function showCopy(e) {
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
var id = dataItem.EItemID;
$.ajax({
url: "/Admin/CopyItem",
//send current record ID to the server
data: { id: dataItem.EItemID },
error: function () {
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);
}
},
success: function (data) {
window.location = '/Admin/CopyItem?id=' + id;
}
})
}
function selectedIndexChanged(e) {
var value = this.value();
var grid = $("#ManageItems").data("kendoGrid");
if (value) {
grid.dataSource.filter({ field: "ECatID", operator: "eq", value: value });
} else {
grid.dataSource.filter({});
}
return;
}
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) {
$(".ref-success").load(window.location + " .ref-success")
}
</script>
The showDetails() function is always being fired... Any help would be greatly appreciated! Thanks!
When in the Kendo editor image browser, there is a delete button that is only visible when a file or folder is selected. It invokes the "Destroy" post. When pressed a javascript confirmation is invoked with the message "Are you sure you want to delete "{fileName}"". How would I override this message in MVC Razor.
Thanks