Hi,
I am trying to implement same way as ASP.NET Core PDF Export Key Features Demo | Telerik UI for ASP.NET Core
but Its exporting in client side but it's not going to controller. Don't know what mistake I am doing. Is there a way to send the pad to controller and send it to email attachment. Below is my code.
$("#btnSubmit").on("click", function (e) {
e.stopPropagation();
e.preventDefault();
var sigval = signature.value();
$('#lblSearchError').text('');
if (sigval === undefined || sigval === '') {
$('#lblSearchError').text('*Signature field is required.');
} else {
var data = $("#submitForm").serializeArray();
var obj = { name: 'signature', value: sigval };
data.push(obj);
// Convert the DOM element to a drawing using kendo.drawing.drawDOM
kendo.drawing.drawDOM($("#mainContect"))
.then(function (group) {
// Render the result as a PDF file
return kendo.drawing.exportPDF(group, {
paperSize: "auto",
margin: { left: "1cm", top: "1cm", right: "1cm", bottom: "1cm" }
});
})
.done(function (data) {
// Save the PDF file
kendo.saveAs({
type: 'POST',
dataURI: data,
fileName: "Provider.pdf",
proxyURL: '@Url.Action("Submit", "Provider")'
});
});
}
});I tried proxyURL AND URL none of them worked. When I clicked on submit button it's just downloading the pdf file. But it not hitting controller.
and in controller
[HttpPost]
public ActionResult Submit(string contentType, string base64, string fileName)
{
//if (!ModelState.IsValid)
//{
// data.Id = 0;
// return Json(data, JsonRequestBehavior.AllowGet);
//}
//var providerData = portalServices.saveProviderData(data);
// return Json(providerData, JsonRequestBehavior.AllowGet);
var fileContents = Convert.FromBase64String(base64);
return File(fileContents, contentType, fileName);
}The Value Axis isn't showing a DateTime like '5/1/2023 10:00 AM' which is the same DateTime format that the data from my stored procedure is using. I'd like the value axis to show each hour of the day.
Attached is a screenshot of the grid. Thanks!
Here's the chart's code:
@(Html.Kendo().Chart<BatchPlantHourlyOutputViewModel>()
Hi,
I created a TileLayout with MVC
@(Html.Kendo().TileLayout()
.Name("zoneWorkflow").Columns(1)
.Gap(g => g.Columns(8).Rows(8))
.Columns(1)
.Reorderable(true)
.Resizable(true)
.HtmlAttributes(new { Title = this.LocalResources("LegendeEtapes") })
.RowsHeight("auto"))On the header template I added a button to remove tile with handle to
removeOperationBox(e) { // e is a KendoButton into Header tile
const itemId = e.sender.element.parents("div[role='listitem']").attr("id");
const workflow = $("#zoneWorkflow").data("kendoTileLayout");
const index = workflow.items.findIndex(i => i.id === itemId);
workflow.items.splice(index, 1);
}Hello,
I'm using a Grid control with virtual scrolling. When I export to PDF, the content runs right off of the bottom of the page without breaking to a new page.
I have my datasource's page size set to 100 records to limit the number of times the grid will need to fetch new data from the server. If I change this to only 5 records, for example, then the PDF will create a page break after 5 records. However, I am also using grouping on the data. If every row is in its own group, I can get about 6 or 7 rows onto a page. If every row falls under the same group, I can get about 13-15 rows onto a page. Because the number of rows per page may vary, I can't resort to setting the page size on the datasource.
My main concern at the moment is getting automatic page breaking to work. In the screenshot I've attached, you can see that there is still some data at the very bottom of the page that is cut off. There should be 11 rows of data, across 6 groups, but only 9 rows manage to fit onto the page. Relevant code below:
.Pdf(pdf => pdf
.FileName("BidAwards.pdf")
.AllPages()
.PaperSize("A4")
.Landscape()
.AvoidLinks()
)
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(100)
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(col => col.BidId))
.Read(read => read.Action("BidAwardGridData", "Reports", Model))
.Group(groups => groups.Add(col => col.GroupValue))
)
I'd also like to find a way to keep entire groups of rows on a page if possible. In other words, if the whole group won't fit on the remainder of the page, break to a new page for that group.
Unfortunately, for the time being I'm stuck on an older version of the Telerik controls, and can't easily update until after this development cycle is completed (unless it's necessary to fix this).
Thanks!!!
We recently updated our nuget reference for "Telerik.UI.for.AspNet.Core" to Version="2023.2.606", and the Select All checkbox stopped working. (It only selects the first row)
It works using Version="2020.2.617"
Here is one of our grids:
<div class="table table-responsive" style="background-color:#444547">
@(Html
.Kendo()
.Grid<ViewModelRedacted>()
.Name("grdUnitsList")
.Columns(columns =>
{
columns.Select().Width("20px");
columns.Bound(c => c.Id).Hidden(true);
columns.Bound(c => c.Name).Title(UnitsController.NameColumn);
})
.Selectable(s => s.Mode(GridSelectionMode.Multiple))
.ColumnMenu()
.ToolBar(tool => tool.Excel())
.Excel(ex => ex
.FileName("Units.xlsx")
.Filterable(true)
.AllPages(true)
)
.Navigatable()
//.Scrollable()
.Pageable()
.Filterable()
.Sortable(sortable =>
{
sortable.SortMode(GridSortMode.SingleColumn);
})
.Resizable(resize => resize.Columns(true))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Model(model => model.Id(p => p.Id))
.ServerOperation(false)
.Read(read => read.Action("GetUnits", "Units"))
)
)
</div>Hi,
From this Model :
publicclassMyRowData
{
public int Id { get; set; }
public SelectList Values { get; set; }
public string Value { get; set; }
}
publicclassMyGridData
{
public IEnumerable<MyRowData> Rows { get; set; }
}I want to bind my model to a grid in view like :
@(Html.Kendo.Grid(Model.Rows)
.Name("myGrid")
.Columns(c =>
{
c.Bound(i => i.Id).Visible(false);
c.ForeignKey(t => t.Value, t => t.Values); //Here is the bind for drop downlist (différent for each row
//And how can achieve this ?
})
.Navigatable()
.Scrollable()))Thanks for help
Hi ,
I am using Telerik.UI.for.AspNet.Core version 2020.3.915
I have created dynamic kendo grid using jquery. my model will vary depending in columns from db. So I am gettign the data as json from DB and creating my grid. i am able to achieve it, But when I try to edit the column values, I am unable to call the controller mthod with proper values from UI. I wanted to do batch edit. But when I use the below code , my controller is getting called multiples times for each edit. Also ,t he value passed is not a proper array. It is in Json format . but looks like { Steer_ID:23,SteerMaximun:34,.......} . Please hepl me to send all the row values that are edited in jason format to the comtroller.
js:
function generateMarginSnapshotColumns(gridData, isEditable) {
var isdisable = "";
if (!isEditable)
isdisable = "disabled";
// initiate the column array
var columns = [];
var groupedColumns = [];
//initiate a counter, used to work out which column we are dealing with
var columnIndex = 0;
var groupedColumnIndex = 0
// define the desired order of the columns
var columnOrder = {
KPI_UNIT_CODE: 1,
KPI_CLASS_DISPLAY_NAME: 2,
STEER_VALUE: 3,
STEER_MAXIMUM_VALUE: 4,
STEER_MINIMUM_VALUE: 5,
DIRECTION_CODE: 6,
MARGIN_DELTA: 7,
DOI: 8,
ENS: 9,
CREATION_USER_ID: 50,
CREATION_DATE: 51,
LAST_UPDATE_USER_ID: 52,
LAST_UPDATE_DATE: 53
// Add more columns and their desired order as needed
};
var NoDisplayColumns = ["STEER_ID", "KPI_SITE_HIERARACHY_ID", "KPI_CLASS_GROUP_CODE", "ACKNOWLEDGEMENT_IND", "KPI_AREA_NAME", "KPI_UNIT_NAME"];
// iterate all of the data items in the first element of the returned JSON data
for (var dataItem in gridData) {
var colTitle = dataItem.replace('_', ' ');
var dataItemField = dataItem;
// create the columns and set up the look and feel - first three are always present and fixed in place
switch (dataItemField) {
case "CREATION_USER_ID":
case "CREATION_DATE":
case "LAST_UPDATE_USER_ID":
case "LAST_UPDATE_DATE":
columns.push({ field: dataItemField, title: colTitle, width: 100, locked: true, hidden: true, headerAttributes: { style: "text-align: left" }, order: columnOrder[dataItemField], editable:true });
break;
case "KPI_UNIT_CODE":
columns.push({ field: dataItemField, title: "UNIT", width: 200, locked: true, headerAttributes: { style: "text-align: left" }, order: columnOrder[dataItemField], editable: true });
break;
case "KPI_CLASS_DISPLAY_NAME":
columns.push({ field: dataItemField, title: "KPI", width: 200, locked: true, headerAttributes: { style: "text-align: left" }, order: columnOrder[dataItemField],editable:true });
break;
case "DOI":
columns.push({ field: dataItemField, title: "Daily Opertor Input", width: 200, headerAttributes: { style: "text-align: left" }, order: columnOrder[dataItemField], editable: !isEditable });
break;
case "ENS":
columns.push({ field: dataItemField, title: "ENS Input", width: 200, headerAttributes: { style: "text-align: left" }, order: columnOrder[dataItemField], editable: !isEditable });
break;
default:
if (columnOrder.hasOwnProperty(dataItemField)) {
columns.push({
field: dataItemField,
title: colTitle,
width: 120,
headerAttributes: { style: "text-align: center;white-space: normal" },
attributes: { style: "text-align: center" },
order: columnOrder[dataItemField],
editable: !isEditable
//template: "<div><input " + isdisable + " type='textbox' onchange='javascript:SaveSteerRow(\"" + colTitle + "\", #:Steer_ID#,this)' value='#:" + dataItemField + "#' > </input> <div id='spn#:Steer_ID#" + dataItemField + "'></div></div>"
});
}
else {
if (NoDisplayColumns.includes(dataItemField))
break;
columns.push({
field: dataItemField,
title: colTitle,
width: 120,
hidden: true,
headerAttributes: { style: "text-align: center;white-space: normal" },
attributes: { style: "text-align: center" },
order: columnOrder[dataItemField],
editable: !isEditable
//template: "<div><input " + isdisable + " type='textbox' onchange='javascript:SaveSteerRow(\"" + colTitle + "\", #:Steer_ID#,this)' value='#:" + dataItemField + "#' > </input> <div id='spn#:Steer_ID#" + dataItemField + "'></div></div>"
});
}
break;
}
// increment the counter so we know when we are done with fixed columns
columnIndex += 1;
}
return columns;
}
function SaveSteerRow(colName, steerId, txtBox) {
if (txtBox.checked) {
txtBox.value = '1';
}
else {
txtBox.value = '0';
}
var fd = new FormData();
fd.append("steerId", steerId);
fd.append("colName", colName);
var id = "spn" + userId + colName.replace(' ', '_');
$.ajax({
async: true,
type: "POST",
url: "/MarginSteerConstraint/UpdateSnapShot",
beforeSend: function (xhr) {
$("#" + id).html("Saving...");
xhr.setRequestHeader("XSRF-TOKEN",
$('input:hidden[name="__RequestVerificationToken"]').val());
},
data: fd,
contentType: false,
processData: false,
success: function (response) {
$("#" + id).html("");
console.log('UpdateSnapShot - Success');
},
error: function (e) {
$("#" + id).html("Error...");
console.log("Error Logged : ")
console.log(e);
}
});
}
var grid;
function LoadSnapShotGrid() {
var siteId = selectedSnapSite.SiteType == "Unit" ? selectedSnapSite.SiteHierarchyId : selectedSnapSite.ID;
$("#grdSnap").html("");
$.ajax({
'async': true,
'type': "GET",
'global': false,
'url': "/MarginSteerConstraint/ReadSnapShot",
'data': { 'request': "", 'siteType': selectedSnapSite.SiteType, 'ID': siteId, 'target': 'arrange_url', 'method': 'method_target' },
'success': function (response) {
console.log('ReadSnapShot - Success');
snapShotData = JSON.parse(response.SnapShot);
var isEditable = response.IsEditable;
generateGrid(snapShotData, isEditable);
//kendo.ui.progress(windowWidget.element, false);
}
});
//bindSaveButtonEvent();
}
function bindSaveButtonEvent() {
// Unbind any existing event handlers to avoid multiple bindings
$("#grdSnap").off("click", ".k-grid-save-changes");
// Bind the event handler for the "save" button
$("#grdSnap").on("click", ".k-grid-save-changes", function () {
// Code to handle the button click event
var grid = $("#grdSnap").data("kendoGrid");
grid.dataSource.sync();
});
}
LoadSnapShotGrid();
function generateModel(gridData) {
var model = {};
model.id = "STEER_ID";
model.id = "KPI_SITE_HIERARCHY_ID";
model.id = "KPI_CLASS_GROUP_CODE";
var fields = {};
for (var property in gridData) {
//if (property.indexOf("ID") !== -1) {
// model["id"] = property;
//}
var propType = typeof gridData[property];
if (propType === "number") {
fields[property] = {
type: "number",
//validation: {
// required: true
//}
};
if (model.id === property) {
fields[property].editable = false;
//fields[property].validation.required = false;
}
} else if (propType === "boolean") {
fields[property] = {
type: "boolean"
};
} else if (propType === "string") {
var parsedDate = kendo.parseDate(gridData[property]);
if (parsedDate) {
fields[property] = {
type: "date"
//validation: {
// required: true
//}
};
isDateField[property] = true;
} else {
fields[property] = {
type: "string"
//validation: {
// required: true
//}
};
}
} else {
fields[property] = {
//validation: {
// required: true
//}
};
}
}
model.fields = fields;
return model;
}
// function takes the JSON data, and dynamically produces a column set, the data schema and binds the grid
function generateGrid(gridData, isEditable) {
var model = generateModel(gridData[0]);
console.log(model);
var columns = generateMarginSnapshotColumns(gridData[0], isEditable);
console.log(columns);
// set up the grid
grid = $("#grdSnap").kendoGrid({
toolbar: ["save","cancel","excel"],
excel: {
fileName: "MarginSteerSnapshot",
filterable: true
},
dataSource: {
data: gridData,
pageSize: 20,
autoSync: false,
schema: {
model: model
},
transport: {
read: function (options) {
options.success(gridData);
},
update: function (options) {
debugger;
var fd = new FormData();
fd.append("steerData", kendo.stringify(options.data));
//alert(kendo.stringify(options.data));
$.ajax({
url: "/MarginSteerConstraint/UpdateSnapShot",
//dataType: "json",
type: "POST",
contentType: false,
processData: false,
beforeSend: function (xhr) {
// $("#" + id).html("Saving...");
xhr.setRequestHeader("XSRF-TOKEN",
$('input:hidden[name="__RequestVerificationToken"]').val());
},
data: fd,
success: function (response) {
// Handle the success response
console.log(response);
options.success(response); // Notify the transport that the update was successful
},
error: function (xhr, status, error) {
// Handle the error response
console.error(error);
options.error(xhr, status, error); // Notify the transport about the error
}
});
}
},
parameterMap: function (options, operation) {
if (operation === "update") {
console.log("in parameter map");
console.log(JSON.stringify(options.data));
//var updatedData = options.data; // Get the updated data object
//alert(updatedData);
//// Convert the updatedData object to JSON
//var SnapShot = kendo.stringify(updatedData);
// Create a dynamic object to send to the controller method
//var SnapShotViewModel = {
// "SnapShot": kendo.stringify(options.data),
// "isEditable": true
//};
// Convert the dynamicObject to JSON
//var dynamicJson = JSON.stringify(SnapShotViewModel);
return JSON.stringify(options.data);
}
}
},
pageable: {
refresh: true,
pageSizes: [20,50,100, 200, "all"],
},
columnMenu: true,
columns: columns,
sortable: true,
filterable: true,
width: "auto",
resizable: true,
editable: "incell",
batch:true,
serverOperation :false,
pageSize: 20
});
}
UI:
<div>
<div>
<div id="grdSnap"></div>
</div>
</div>
Controller:
[HttpPost]Hello, I have a problem with integrating the Kendo().Stepper() into my application. When I tried to add it in, the progress meter does not align with each point. Any idea of what causes this and how can I solve this?

Hello, I have a grid I am using to display detail info on a view. The columns .ClientTemplate logic works fine in a View.
However, the client wants the detail view to be displayed as a Modal Window over the summary listing. I have this working as a PartialView however the logic in the .ClientTemplate does not work in the Modal windows.
This is the working Code in the view. The highlighted section is the ClientTemplate that DOES NOT work when rendered as a PartialView in the Modal window.
@(Html.Kendo().Grid(Model.claimDetails)
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.Ln).ClientTemplate(
"# if (Ln == '0') { #" +
"Total Chrg" +
"# } else { #" +
"Line #= Ln #" +
"# } #"
);
columns.Bound(p => p.Chrg).Format("{0:C}").Title("Charge");
columns.Bound(p => p.IncurFrm).Format("{0:MM/dd/yyyy}").Title("Svc Date").Width(130);
columns.Bound(p => p.ProcRev).Title("Proc/Revenue Code").Width(130);
columns.Bound(p => p.OCAllowed).Format("{0:C}").Title("OC allow").Width(130);
columns.Bound(p => p.OCPaid).Format("{0:C}").Title("OC Paid").Width(130);
columns.Bound(p => p.BenAmt).Format("{0:C}").Title("Benefit Amt.").Width(130);
columns.Bound(p => p.OCDedAmt).Format("{0:C}").Title("OC Ded").Width(130);
columns.Bound(p => p.CoInsurDed).Format("{0:C}").Title("Ded Amt").Width(130);
columns.Bound(p => p.CoInsur1).Format("{0:C}").Title("Coins Amt 1").Width(130);
columns.Bound(p => p.Copay).Format("{0:C}").Title("CoPay Amt");
columns.Bound(p => p.RemarkCd).Title("Remark Cd");
columns.Bound(p => p.InElig).Format("{0:C}").Title("Tot Inelig Amt");
columns.Bound(p => p.PdClmnt).Format("{0:C}").Title("Pd to Ins");
columns.Bound(p => p.PdProv).Format("{0:C}").Title("Pd to Prov");
})
.HtmlAttributes(new { style = "height: 600px;" })
.Sortable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.ServerOperation(false)
)
)