Telerik Forums
Kendo UI for jQuery Forum
12 answers
1.8K+ views

Hi,

 

I'm migrating an very old kendo's version to the latest and i want to check all my code for make it pretty. 

In grid, we need to have some editable fields and other readonly fields. But readonly's fields are computed with the editable.

For example, i have a product's grid with quantity, unit price and total. Unit price and Total, must be readonly, but the user can change quantity. Total is automatically calculated by unit price multiple quantity. 

 

Actually, in our code, iclose cell when enter on edit mode if it's Unit price and quantity. But i seeing in the manual,  i can use de Model editable flag. But when i use it, i can't change Total value using "set" method.

 

https://fiddle.jshell.net/muadhib/c1qLvax2/2/

 

Any body know how to do that in the prettiest way ?

 

Thx

Alex Hajigeorgieva
Telerik team
 answered on 16 Jun 2016
1 answer
496 views

Hi there. I'm looking to do some on-the-fly calculations.I want to multiply the values in a Quantity field and times it by a Unit Price field and update the input field that's within the Ext Price field.

I was going to try and do it, in the save event, and I've done that in the past, so when a user would tab off the field, it would do the calculation. But now my editable property is "inline" and not "true" so it appears I can't do that now, the editable mode like this effects the timing of such events.

I want the user to see the updated value as they are tabbing around the row, not when they simply save.

The input fields seem to be kendo numerictextboxes when I'm in edit mode.

Here's my grid part.

01.$("#gridLineItems").kendoGrid({
02.                                        dataSource: dataSource,
03.                                        navigatable: true,
04.                                        pageable: true,
05.                                        editable: {
06.                                            mode: "inline"
07.                                        },
08.                                        //editable: true,
09.                                        toolbar: [{ name: "create", text: "Insert Line" }, { name: "cancel" }, { name: "save" }],
10.                                        columns: [
11.                                            { field: "LineItemPK", title: "LineItemPK", hidden: true },
12.                                            { field: "Quantity", title: "Qty", validation: { min: 0 }, editor: editorNumberQty, width:50 },
13.                                            { field: "UnitPrice", title: "Unit Price", editor: editorNumber, width: 75 },
14.                                            { field: "ExtPrice", title: "Ext. Price", editable: false, attributes: { "class": "ExtPrice" }, width: 75 },
15.                                            { field: "ProductFK", title: "ProductFK", attributes: { "class": "ProductFK" }, hidden: true },
16.                                            { field: "Description", title: "Product", editor: productDropDownEditor, width: 200 },
17.                                            { field: "ProductID", title: "Product ID" },
18.                                            { field: "UoM", title: "UoM" },
19.                                            { field: "InvoiceNum", title: "Invoice #" },
20.                                            { field: "DepFunction", title: "Dep. Funct." },
21.                                            { field: "CostCenterFK", title: "CostCenterFK", hidden: true },
22.                                            { field: "CostCenterDescription", title: "Cost Center", editor: csDropDownEditor },
23.                                            { field: "AccountFK", title: "G/L", hidden: true },
24.                                            { field: "GLAccount", title: "G/L", editor: glDropDownEditor },
25.                                            { field: "OrderFK", title: "OrderFK", editable: false, hidden: true },
26.                                            { command: ["edit", "destroy"], title: " ", width: 140 }
27.                                        ],
28.                                        selectable: true,
29.                                        edit: function (e) {
30.                                             
41.                                            setTimeout(function () {
42.                                                var input = e.container.find("input");
43.                                                input.select();
44.                                            });
45. 
46.                                        },
47.                                        change: function (e)
48.                                        {
49. 
50.                                        },
51.                                        save: function (e) {
52. 
53.                                        },
54.                                        saveChanges: function (e)
55.                                        {
56.                                            
57.                                        }
58.                                    });
59. 
60.                                });

 

Also, I tried the if (e.field == "UnitPrice") business, but that doesn't fire at all, unless I have editalble be inline (which doesn't make sense to me anyways, true or inline both seem to present an inline way of editing, but I digress.). I tried this because I only wanted it to fire it a user was tabbing off of UnitPrice or Quantity. I also tried e.values.Quantity, this doesn't help either, because it only seems to know the value if you are on the field in question. So, if I tab off of Quantity and I'm looking for e.values.Quantity, it gets that, but not the value of UnitPrice. 

Thanks in advance.

 

PS - also, if you look at my line 41, the code that's supposed to focus on a field when I tab into it, it's not firing at all. Again, I think because I'm not in editable mode - true. This whole editablemode seems to be screwing a lot up for me. But I needed to do it because delete wasn't working without it.

Dimiter Topalov
Telerik team
 answered on 16 Jun 2016
8 answers
386 views

We got pushed Chrome Version 50.0.2661.75 m (64-bit) today and ever since then I get this in the console...

 

VM2478:544 Detected Kendo UI version: "2016.1.217"
VM2478:494 Uncaught ReferenceError: $0 is not defined

If I uninstall the Inspector the error goes away

If I reinstall it comes back

 

T. Tsonev
Telerik team
 answered on 16 Jun 2016
15 answers
1.2K+ views
Hello,

It looks like following code works ok if createNew : "false", but fails when createNew : false. Is there any workaround?

<input type="radio" value="true" name="type" data-bind="checked: createNew" />
<input type="radio" value="false" name="type"" data-bind="checked: createNew" />







Drazen
Top achievements
Rank 1
 answered on 16 Jun 2016
1 answer
265 views

I have a dojo with instructions (on the dojo rendered page) on how to reproduce the issue:  http://dojo.telerik.com/Afaji/4

If you (1) Group a column in the grid, then (2) manually expand the width of column(s), (3) Run columns thru grid's "autoFitColumn" function....

Expected behavior:  All the columns reduce/expand in size to only accommodate the data within (works fine if no column grouping)

Actual behavior: The columns do NOT reduce in size (to only accommodate the data within).

Stefan
Telerik team
 answered on 16 Jun 2016
2 answers
179 views

Hi,

I just started to work on this platform last week.

I have created a table and want to add data to it on submit button click.My table name is Doctor. The data is not syncing to table i guess.This is my code .Api key is not mentioned for obvious reason.Also whenever I logout all the changes made in code disappears.I am really new to this platform so please help me out.

app.formView = kendo.observable({
    onShow: function() {},
    afterShow: function() {}
});

// START_CUSTOM_CODE_formView
// Add custom code here. For more information about custom code, see http://docs.telerik.com/platform/screenbuilder/troubleshooting/how-to-keep-custom-code-changes
 
// END_CUSTOM_CODE_formView
(function(parent) {
   var apiKey="";
     var el = new Everlive(apiKey);
     var doc=new kendo.data.DataSource({
          type: "everlive",
         transport: {
            typeName: "Doctor"
        }
     });
    var formViewModel = kendo.observable({
        
        fields: {
            city: '',
            state: '',
            address2: '',
            address1: '',
        },
        submit: function() {
            var add1=$("#add1").val();
             var state=$("#state").val();
             var city =$("#city").val();
            if(add1=="")
                {
                $("#adderr").show();
                    return false;
            }
            if(state==null){
                $("#stateerr").show();
                  return false;
            }
            if(city==""){
                $("#cityerr").show();
 return false;
            }
            
           doc.add({
               Address1:formViewModel.fields.address1,
               City:formViewModel.fields.city,
               State:formViewModel.fields.state
              
           });
           doc.one("sync",this.close);
            doc.sync();
            alert("hello");
            

            

        },
        cancel: function() {}
    });

    parent.set('formViewModel', formViewModel);
})(app.formView);

Thanks, 

Rugved

Rugved
Top achievements
Rank 1
 answered on 16 Jun 2016
1 answer
111 views

Hi,

    I have a Side Menu on my page, which when clicked moves into the page. When the SideMenu moves in, the Gantt Timeline is moving out of the container. It also increases the page width which looks awkward. I tried to work that out using the kendo.resize , but it still remains the same. I am attaching pictures for reference. 

Initial.png - Original Display

Final.png - When Side Menu is toggled

Please try to answer in angular code.

 

Note: I am Using Bootstrap and Angular, 

Thanks

 

Ivan Danchev
Telerik team
 answered on 16 Jun 2016
6 answers
594 views

I am using a Kendo MultiSelect (within a column of a tr-ng-grid) and I am trying to add a functionality where an item is deselected when another is selected.

Ex. I have the options 1, 2, 3,  and UNKNOWN; only 2 and 3 are selected. The rule is when UNKNOWN is selected, the rest are deselected and when 1, 2, or 3 is selected, UNKNOWN is deselected.

The problem that I am facing is that the model and the view is not always in sync, which poses a problem.

 

Here is the code.

index.html (short version)

1.<dir-multi-select selected-items="gridItem.items" />

directive.js

01.(function() {
02.    'use strict';
03.    angular.module('moduleA').directive('dirMultiSelect', function() {
04.        return {
05.            restrict : 'E',
06.            scope : {
07.                selectedItems : '='
08.            },
09.            controller : 'MultiSelectController',
10.            templateUrl : 'multiselect.html',
11.            replace : true
12.        }
13.    })
14.})();

multiselect.html

01.<div ng-init="init()">
02.    <select kendo-multi-select
03.        id="'multiSelect'"
04.        ng-if="dataSource"
05.        k-data-source="dataSource"
06.        k-data-text-field="'name'"
07.        k-data-value-field="'id'"
08.        k-ng-model="selectedItems"
09.        k-rebind="selectedItems"
10.        k-value-primitive=true
11.        k-auto-close=false
12.        k-data-placeholder="'Select items...'"
13.        k-on-select="onSelect(kendoEvent)">
14.    </select>
15.</div>

multiselect.controller.js

01.(function() {
02.    angular.module('moduleA').controller(
03.            'MultiSelectController',
04.            [
05.                    '$scope',
06.                    function($scope) {
07.                        $scope.init = function() {
08.                                $scope.dataSource = //http call
09.                        }
10. 
11.                        $scope.onSelect = function(kendoEvent) {
12.                            var selectedItem = kendoEvent.sender.dataItem(kendoEvent.item.index());
13.                            if (selectedItem ) {
14.                                autoDeselectItems(kendoEvent, selectedItem);
15.                            }
16.                        }
17. 
18.                        function autoDeselectItems(kendoEvent, selectedItem) {
19.                            if (isItemIdUnknown(selectedItem.id)) {
20.                                kendoEvent.preventDefault();
21.                                if (!doesSelectedItemContainUnknown()) {
22.                                    setSelectedItemsToUnknown();
23.                                }
24.                            }
25.                            else {
26.                                if (doesSelectedItemsContainUnknown()) {
27.                                    kendoEvent.preventDefault();
28.                                    setSelectedItems(selectedItem);
29.                                }
30.                                else {
31.                                    if (doesSelectedItemsContain(selectedItem.id)
32.                                            && $scope.selectedItems.length == 1) {
33.                                        setSelectedItemsToUnknown();
34.                                    }
35. 
36.                                }
37.                            }
38.                        }
39. 
40.                        function isItemIdUnknown(id) {
41.                            return id == "0";
42.                        }
43. 
44.                        function doesSelectedItemsContainUnknown() {
45.                            for (var i = 0; i < $scope.selectedItems.length; i++) {
46.                                if (isItemIdUnknown($scope.selectedItems[i].id)) {
47.                                    return true;
48.                                }
49.                            }
50.                            return false;
51.                        }
52. 
53.                        function doesSelectedItemsContain(id) {
54.                            for (var i = 0; i < $scope.selectedItems.length; i++) {
55.                                if ($scope.selectedItems[i].id == id) {
56.                                    return true;
57.                                }
58.                            }
59.                            return false;
60.                        }
61. 
62.                        function removeUnknownFromSelectedItems() {
63.                            for (var i = 0; i < $scope.selectedItems.length; i++) {
64.                                if ($scope.selectedItems[i].id == 0) { // "UNKNOWN"
65.                                    $scope.selectedItems.splice(i, 1);
66.                                    break;
67.                                }
68.                            }
69.                        }
70. 
71.                        function setSelectedItemsToUnknown() {
72.                            $scope.selectedItems = [ {
73.                                id : "0",
74.                                name : "UNKNOWN"
75.                            } ];
76.                        }
77. 
78.                        function setSelectedItems(ids) {
79.                            if (ids) {
80.                                $scope.selectedItems = [];
81.                                if (ids.length) {
82.                                    for (var i = 0; i < ids.length; i++) {
83.                                        $scope.selectedItems.push({
84.                                            id : ids[i].id,
85.                                            name : ids[i].name
86.                                        });
87.                                    }
88.                                }
89.                                else {
90.                                    $scope.selectedItems.push({
91.                                        id : ids.id,
92.                                        name : ids.name
93.                                    });
94.                                }
95.                            }
96.                        }
97.                    } ]);
98.})();

a

Alex Hajigeorgieva
Telerik team
 answered on 16 Jun 2016
3 answers
670 views

I have strange and unexpected behavior with my Grid with multiple headers (3 levels) when i resize window. 

Here is how it's look like: https://gyazo.com/969e62e758a1b583c06cdcc6af056acf

They dissapear after resize . I'm using  autoFitColumn() for all columns in Grid, and some cells keep width stable, but these with multiple headers has some problems.

 

var gridOptions = {
        pdf: {
            allPages: true,
            avoidLinks: true,
            paperSize: "A4",
            margin: { top: "2cm", left: "1cm", right: "1cm", bottom: "1cm" },
            landscape: true,
            repeatHeaders: true,
            template: $("#page-template").html(),
            scale: 0.5,
            title: 'Raport dzienny'
        },
        columnMenu : true,
        groupable: true,
        scrollable: true,
        sortable: true,
        filterable: true,
        reorderable: true,
        lockable: true,
        resizable: true,
        dataSource:{
            data: this.data,
        },
        columns : options.columns || this.generateColumns(),
    };

This specific column: 

{
            title: 'Liczniki', columns: [
            {
                title: 'Kilometrzy', columns: [
                   {title: 'PoczÄ…tek', field: 'begin_km_counter', format: "{0:n2}"},
                   {title: 'Koniec', field: 'end_km_counter', format: "{0:n2}"}
            ]
            },
            {
                title: 'Motogodziny', columns: [
                   {title: 'PoczÄ…tek', field: 'begin_mth_counter'},
                   {title: 'Koniec', field: 'end_mth_counter'}
            ]
            },
            {
                title: 'PrzepÅ‚ywomierz', columns: [
                   {title: 'PoczÄ…tek', field: 'begin_flowmeter_counter'},
                   {title: 'Koniec', field: 'end_flowmeter_counter'}
            ]
            }
        ]
        },

Stefan
Telerik team
 answered on 16 Jun 2016
4 answers
398 views

Hi,

I'm trying to export a Grid to PDF as shown in this example:

http://demos.telerik.com/kendo-ui/grid/pdf-export

 

The problem is that I need to use a bigger pageSize and I just want to export the current page.

If I just modify those options on the given example (setting allPages: false and pageSize:50 ) the resulting PDF splits the current page on 6 chunks, but prints all six of them on the same page, overlapping the output as can be seen on the attached file.

Am I doing something wrong?

Is there any way of achieving the desired behavior?

 

Thanks,

Carlos

carlos
Top achievements
Rank 1
 answered on 16 Jun 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
ScrollView
Switch
TextArea
BulletChart
Licensing
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
FloatingActionButton
CircularGauge
ColorGradient
ColorPalette
DropDownButton
TimeDurationPicker
ToggleButton
TimePicker
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
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?