Telerik Forums
Kendo UI for jQuery Forum
1 answer
1.3K+ views

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.

T. Tsonev
Telerik team
 answered on 19 Feb 2016
8 answers
4.4K+ views
I haven't played with this too much as my javascript skills aren't super great, but I am wondering if there is a way to show a loading animation (something like a spinning circle loading gif) in the kendo window that will be displayed when ajax is used to call the window contents. The reason I ask is because I am trying to load some telerik reports in popup windows, and there is always a good 5-10 second delay where the window is just white/blank before the report even initializes. It would really just be great for letting the user know that the window needs a few seconds to load, and just to be patient. Any official or unofficial solutions are welcomed!
Alex Gyoshev
Telerik team
 answered on 19 Feb 2016
2 answers
279 views

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()
    )

Alexander Valchev
Telerik team
 answered on 19 Feb 2016
1 answer
599 views

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();
        }
    };

Here is a custom event to handle the 'Tab' keypress. The point of this is I want a new record automatically added to the grid if the user presses 'Tab' at the end of the last line:

$("#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.

 

Alexander Valchev
Telerik team
 answered on 19 Feb 2016
1 answer
288 views
Can we make Nested grid to nth level with child grid as collapsible ?
Dimiter Madjarov
Telerik team
 answered on 19 Feb 2016
2 answers
457 views

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

Kiril Nikolov
Telerik team
 answered on 19 Feb 2016
1 answer
174 views
Hello Nikolai,

I hope you are doing well!

Im currently working again on the project I showed you during our training at Ometa. I have a question about the logarithmic scaling of the valueAxis of a bar chart. In the screenshot below you can see the results however it is not presented logical to our key-users. They are excepting the bars to start at 0.1 even the longest ones.

In screenshot 2 you can see what I mean however it seems that only values greater than 1 are presented on the right side of the chart and values smaller than 1 are presented on the left side of the chart.
Would it be possible to have all the bars starting on the left side of the chart even if they are smaller than 1?

Thanks in advance!!

Kind regards

EZ
Top achievements
Rank 2
 answered on 18 Feb 2016
4 answers
196 views

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
                    }
                });
            }

Carlos
Top achievements
Rank 1
 answered on 18 Feb 2016
2 answers
142 views

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?

Shawn
Top achievements
Rank 1
 answered on 18 Feb 2016
2 answers
1.0K+ views
Hallo,

Is there any way to make my grid cell to show only ie 50 characters from what i put in that cell?
And is it possible to bind this cell to a click event on which the cell would become great enough to show all sentence?

Thanks in advance
Kurtis
Top achievements
Rank 1
 answered on 18 Feb 2016
Narrow your results
Selected tags
Tags
Grid
General Discussions
Charts
Data Source
Scheduler
DropDownList
TreeView
MVVM
Editor
Window
DatePicker
Spreadsheet
Upload
ListView (Mobile)
ComboBox
TabStrip
MultiSelect
AutoComplete
ListView
Menu
Templates
Gantt
Validation
TreeList
Diagram
NumericTextBox
Splitter
PanelBar
Application
Map
Drag and Drop
ToolTip
Calendar
PivotGrid
ScrollView (Mobile)
Toolbar
TabStrip (Mobile)
Slider
Button (Mobile)
Filter
SPA
Drawing API
Drawer (Mobile)
Globalization
LinearGauge
Sortable
ModalView
Hierarchical Data Source
Button
FileManager
MaskedTextBox
View
Form
NavBar
Notification
Switch (Mobile)
SplitView
ListBox
DropDownTree
PDFViewer
Sparkline
ActionSheet
TileLayout
PopOver (Mobile)
TreeMap
ButtonGroup
ColorPicker
Pager
Styling
Chat
MultiColumnComboBox
Dialog
DateRangePicker
Checkbox
Timeline
Drawer
DateInput
ProgressBar
MediaPlayer
ImageEditor
TextBox
OrgChart
Accessibility
Effects
PivotGridV2
Licensing
ScrollView
Switch
TextArea
BulletChart
QRCode
ResponsivePanel
Wizard
CheckBoxGroup
Localization
Barcode
Breadcrumb
Collapsible
MultiViewCalendar
Touch
RadioButton
Stepper
Card
ExpansionPanel
Rating
RadioGroup
Badge
Captcha
Heatmap
AppBar
Loader
Security
TaskBoard
Popover
DockManager
TimePicker
FloatingActionButton
CircularGauge
ColorGradient
ColorPalette
DropDownButton
TimeDurationPicker
ToggleButton
BottomNavigation
Ripple
SkeletonContainer
Avatar
Circular ProgressBar
FlatColorPicker
SplitButton
Signature
Chip
ChipList
VS Code Extension
AIPrompt
PropertyGrid
Sankey
Chart Wizard
OTP Input
SpeechToTextButton
InlineAIPrompt
StockChart
ContextMenu
DateTimePicker
RadialGauge
ArcGauge
AICodingAssistant
SmartPasteButton
PromptBox
SegmentedControl
+? more
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?