Hi.
I export my PDF using the following functions:
$(".export-pdf").click(function() {
// Convert the DOM element to a drawing using kendo.drawing.drawDOM
var fileName = $(this).data('val');
kendo.drawing.drawDOM($("#" + $(this).data('val')))
.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({
dataURI: data,
fileName: fileName + ".pdf",
//proxyURL: "//demos.telerik.com/kendo-ui/service/export"
});
});
});
according to this document: http://docs.telerik.com/kendo-ui/framework/drawing/pdf-output#configuration-Custom
I have defined the font though kendo.pdf.definefont:
kendo.pdf.defineFont({"Verdana" : "/fonts/Verdana.ttf", // this is a URL"Verdana|Bold" : "/fonts/Verdana_Bold.ttf","Verdana|Bold|Italic" : "/fonts/Verdana_Bold_Italic.ttf","Verdana|Italic" : "/fonts/Verdana_Italic.ttf"});
However, i am not sure how to tell the drawDOM object to use the font being defined. because in the example:
var text = new drawing.Text("Hello World", new geo.Point(100, 100));
text.options.set("font", "30px Verdana");
drawing.Text have to be filled with particular text but now i need all the text in the DOM drawing with the custome font.
Thank you.
Why is my grid calling "CreateFooBar" for every row of data when delete and update are submitted? It's probably something stupid but I can't see it.
@(Html.Kendo()
.Grid<FooBarViewModel>()
.Name("FooBarGrid")
.Sortable()
.Scrollable()
.Filterable()
.Resizable(g => g.Columns(true))
.Columns(columns =>
{
columns.Command(command =>
{
command.Edit();
command.Destroy();
}).Width(150);
columns.Bound(g => g.Id).Hidden();
columns.Bound(g => g.Name).Title("Name").Width(200);
columns.Bound(g => g.FooBarNumber).Title("FooBar<br />Number").Width(200);
columns.Bound(g => g.CreatedBy).Width(100).Title("Created By");
columns.Bound(g => g.CreatedDate).Width(100).Title("Created Dt");
columns.Bound(g => g.ModifiedBy).Title("Modified By").Width(100);
columns.Bound(g => g.ModifiedDate).Width(100).Title("Modified Dt");
})
.DataSource(dataSource => dataSource.Ajax()
.Model(model =>
{
model.Id(m => m.Id);
model.Field(p => p.CreatedBy).Editable(false);
model.Field(p => p.CreatedDate).Editable(false);
model.Field(p => p.ModifiedDate).Editable(false);
model.Field(p => p.ModifiedBy).Editable(false);
})
.Batch(false)
.PageSize(25)
.ServerOperation(false)
.Read(read => read.Action("GetFooBars", "FooBar"))
.Create(update => update.Action("CreateFooBar", "FooBar"))
.Update(update => update.Action("UpdateFooBar", "FooBar"))
.Destroy(update => update.Action("DeleteFooBar", "FooBar"))
.Events(ev => ev.RequestEnd("onSave"))
.Events(events => { events.Error("onError"); })
)
.ClientDetailTemplateId("collectionTemplate")
.Events(ev => ev.Edit("onEdit"))
.ToolBar(toolbar =>
{
toolbar.Create().Text("Add FooBar");
})
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Pageable(pager => pager
.Input(true)
.Numeric(true)
.Info(true)
.PreviousNext(true)
.Refresh(true)
.PageSizes(new int[5] { 25, 50, 100, 200, 500 })
)
.ColumnMenu()
)
I'm having an issue with Kendo Grid in Angular where the custom drop down I've implemented will not open when tab navigating to that column. The built in text and number editor fields are editable on tab navigation but my custom drop down will not expand. I have to click on it to get the drop down effect.
My goal here is to allow the user to log an an entire row of data without having to take their hands off the keyboard.
My column is defined like so:
gridColumns.push({ field: currentField.FieldName.replace(/ /g, "_"), title: currentField.FieldName, editor: $scope.dropDownAttEditor, template: function (dataItem) { return $scope.dropDownTemplate(dataItem, currentField.FieldName); }});
My gridOptions are defined as follows:
$scope.gridOptions = { dataSource: new kendo.data.DataSource({ transport: { read: { url: appconfig.basePath + '/api/DrillHoleManager/DrillHoleInterval', type: 'POST', contentType: 'application/json' }, update: { url: appconfig.basePath + '/api/DrillHoleManager/DrillHoleIntervalUpdate', type: 'POST', contentType: 'application/json' }, parameterMap: function (data, operation) { if (operation === "read") { data.DrillHoleId = $scope.entity.Id; data.DrillHoleIntervalTypeId = $stateParams.ddhinttypeid; // convert the parameters to a json object return kendo.stringify(data); } if (operation === 'update') { // build DrillHoleIntervalDto object with all ATT/CMT values to send back to server var drillHoleInterval = { Id: data.Id, Name: data.Name, From: data.From, To: data.To }; drillHoleInterval.Attributes = []; drillHoleInterval.Comments = []; var attributeFields = $.grep($scope.currentFields, function (e) { return e.DrillHoleTabFieldType == DrillHoleTabFieldTypeEnum.IntervalAttribute }); $.each(attributeFields, function (idx, attributeField) { drillHoleInterval.Attributes.push({ Id: attributeField.AttributeDto.Id, LookupId: data[attributeField.FieldName.replace(/ /g, "_")] }); }); var commentFields = $.grep($scope.currentFields, function (e) { return e.DrillHoleTabFieldType == DrillHoleTabFieldTypeEnum.IntervalComment }); $.each(commentFields, function (idx, commentField) { drillHoleInterval.Comments.push({ Id: commentField.CommentDto.Id, Value: ((data[commentField.FieldName.replace(/ /g, "_")] != "") ? data[commentField.FieldName.replace(/ /g, "_")] : null) }); }); return kendo.stringify(drillHoleInterval); } // ALWAYS return options return options; } }, schema: { model: { id : "Id" }}, serverPaging: false, serverSorting: false, serverFiltering: false //,autoSync: true }), columns: gridColumns, dataBound: onDataBound, autoBind: false, navigatable: true, scrollable: false, editable: true, selectable: true, edit: function (e) { var grid = $("#ddhintgrid").data("kendoGrid"); //grid.clearSelection(); grid.select().removeClass('k-state-selected'); // select the row currently being edited $('[data-uid=' + e.model.uid + ']').addClass('k-state-selected'); e.container[0].focus(); } };
$("#ddhintgrid").keydown(function (e) { if (e.key == "Tab") { var grid = $("#ddhintgrid").data("kendoGrid"); var data = grid.dataSource.data(); var selectedItem = grid.dataItem(grid.select()); var selectedIndex = null if (selectedItem != null) { selectedIndex = grid.select()[0].sectionRowIndex; if (selectedIndex == data.length - 1) { // if the bottom record is selected // We need to manually add a new record here so that the new row will automatically gain focus. // Using $scope.addRecord() here will add the new row but cause the grid to lose focus. var newRecord = { From: grid.dataSource.data()[selectedIndex].To }; var currentCmtFields = $.grep($scope.currentFields, function (e) { return e.DrillHoleTabFieldType == DrillHoleTabFieldTypeEnum.IntervalComment; }); $.each(currentCmtFields, function (idx, currentCmtField) { newRecord[currentCmtField.FieldName.replace(/ /g, "_")] = null; }); grid.dataSource.insert(data.length, newRecord); // edit the new row grid.editRow($("#ddhintgrid tr:eq(" + (data.length) + ")")); } } } });Here is my template for the drop down column:
$scope.dropDownTemplate = function (dataItem, fieldName) { var currentLookups = $.grep($scope.currentFields, function (e) { return e.FieldName == fieldName; })[0].AttributeDto.Lookups; var selectedLookup = $.grep(currentLookups, function (e) { return e.Id == dataItem[fieldName.replace(/ /g, "_")]; })[0]; // With the custom dropdown editor when going from null to a value the entire lookup object (id, name) is placed in the // dataItem[field_name] instead of just the id. We need to replace this object with just the id value and return the name of // the lookup to the template. if (typeof selectedLookup == 'undefined' && dataItem[fieldName.replace(/ /g, "_")] != null) { selectedLookup = angular.copy(dataItem[fieldName.replace(/ /g, "_")]); dataItem[fieldName.replace(/ /g, "_")] = selectedLookup.Id; } if (selectedLookup != null && selectedLookup != '') { return selectedLookup.Name; } else { return ''; }};And finally here is the custom editor for the drop down column:
$scope.dropDownAttEditor = function (container, options) { var editor = $('<input k-data-text-field="\'Name\'" k-data-value-field="\'Id\'" k-data-source="ddlDataSource" data-bind="value:' + options.field + '"/>') .appendTo(container).kendoDropDownList({ dataSource: $.grep($scope.currentFields, function (e) { return e.FieldName == options.field.replace(/_/g, ' '); })[0].AttributeDto.Lookups, dataTextField: "Name", dataValueField: "Id" });};I know this is a lot to take in but if you have any questions just let me know.
My ultimate goal is that I want the user to be able to navigate the grid using the 'Tab' key and edit every field without having to use the mouse.
Hey there, I have a panel bar that can have multiple items. I use the select method to do a bunch of code work. I know want to implement an unsaved changes warning on the page so I need to implement a way to stop the panelbar from expanding or collapsing.
I know I can do it from the expand and collapse events - I have tested this and it works great (e.preventDefault()). However since I have all of my coding within the select event and I have other actions that sometimes expand and collapse the panels dynamically I would like the ability to stop the panelbar from expanding and collapsing from the select event. Is that possible? I do see that the select event fires first.
Thanks,
Coty
I'm trying to do a multi checkbox filter in my grid, but something is going wrong and i don't know what, here is my grid configuration.
PS: in $scope.data i have all the data i need
function createGrid() { jQuery("#grid").kendoGrid({ columns: [ { field: "id", title: "ID", menu: false, filterable: { dataSource: $scope.data } }, { field: "invoiceCode", title: "CÓDIGO", width: '180px', filterable: { dataSource: $scope.data } }, { field: "operationCode", title: "COD OPERAÇÃO", width: '200px', filterable: { dataSource: $scope.data } }, { title: 'Tipo', field: "tipoContrato", filterable: { multi: true, dataSource: $scope.data }, width: '120px' }, { field: "contraparteName", title: "NOME EMPRESA", width: '150px', filterable: { dataSource: $scope.data } }, { field: "contraparteCode", title: "RAZÃO SOCIAL", width: '8%', filterable: { dataSource: $scope.data } }, { field: "contraparteCnpj", title: "CNPJ", width: '190px', filterable: { dataSource: $scope.data } }, { field: "nomeContrato", title: "NOME CONTRATO", width: '250px', filterable: { dataSource: $scope.data } }, { field: "energiaRef", title: "QTD. ENERGIA", width: "150px", filterable: { dataSource: $scope.data } }, { field: "preco", title: "PREÇO ENERGIA", width: "150px", filterable: { dataSource: $scope.data } }, { field: "custoEnergia", title: "TOTAL", width: "150px", filterable: { dataSource: $scope.data } }, { field: "statusEnergia", title: "STATUS QTD.", width: "190px", filterable: { dataSource: $scope.data } }, { field: "statusPreco", title: "STATUS PREÇO", width: "190px", filterable: { dataSource: $scope.data } }, { field: "statusGeral", title: "STATUS GERAL", width: "190px", filterable: { dataSource: $scope.data } }, { field: "ciclo", title: "DATA BASE", width: "190px", type: "date", format: "{0:dd/MM/yyyy}", filterable: { dataSource: $scope.data } }, { field: "vencimento", title: "DATA VENCIMENTO", width: "190px", type: "date", format: "{0:dd/MM/yyyy}", filterable: { dataSource: $scope.data } }, { field: "percent", title: "PROCENTAGEM", width: "190px", filterable: { dataSource: $scope.data } }, { field: "statusPagamento", title: "PAGA", width: "190px", filterable: { dataSource: $scope.data } }, { field: "created", title: "CADASTRO", width: "190px", type: "date", format: "{0:dd/MM/yyyy}", filterable: { dataSource: $scope.data } } ], dataSource: { transport: { read: function(options){ var today = new Date(); var mm = today.getMonth()+1; var yy = today.getFullYear(); var date = yy + '-' + mm; var query = { "Options": { "order": [ {"field": "supplyDate"}, {"field": "dInvoiceGroupId"}, {"field": "baseDate"} ], "limit": 20, "page": 1 }, "Criteria": {"baseDate": date} }; query.Options.page = options.data.page; query.Options.limit = options.data.pageSize; if(typeof options.data.sort !== "undefined" && options.data.sort !== null) { for(var i = 0; i< options.data.sort.length; i++) { if(options.data.sort[i].field == "parentName"){ options.data.sort[i].field = "Parent.name" } if(options.data.sort[i].dir === "desc") { query.Options.order = [{ "direction": "descending", "field": options.data.sort[i].field }]; }else { query.Options.order = [{ "direction": "ascending", "field": options.data.sort[i].field }]; } } } var criteria = $scope.buildCriteria(options.data.filter); if(typeof criteria != 'undefined'){ query.Criteria = criteria; } Api.get("Invoices", query, 'gridList').then(function (data) { options.success(data); }, function () { PopupManager.notice(headerPopupManager, bodyPopupManager); }); } }, schema: { data: function(response){ return response.Data; }, model: { fields: { code: {type: "string"}, operationCode: {type: "string"}, invoiceType: {type: "string"}, companyName: {type: "string"}, razaoSocial: {type: "string"}, companyCnpj: {type: "string"}, operationName: {type: "string"}, energiaRef: { type: "number" }, preco: { type: "number" }, custoEnergia: { type: "number" }, qttStatus: {type: "string"}, priceStatus: {type: "string"}, generalStatus: {type: "string"}, ciclo: {type: "date"}, vencimento: {type: "string"}, percent: {type: "string"}, statusPagamento: {type: "string"}, created: {type: "date"} } }, total: function(response) { if(typeof response.MetaData.PaginationInfo != 'undefined'){ return response.MetaData.PaginationInfo.total; } return 0; } }, serverPaging: true, serverFiltering: true, serverSorting: true }, editable: true, reorderable: true, resizable: true, sortable: true, selectable: "multiple", columnMenu: true, filterable: true, pageable: { pageSize: 20, refresh: true, pageSizes: true, buttonCount: 5 } }); }I'm using TypeScript and the this object inside the upload event is the instance of the kendoupload, not the angular controller.
To get at a value on the controller, I'm currently using this.$angular_scope.vm.datavariable but is this the best way to access controller variables within the upload event?