Telerik Forums
Kendo UI for jQuery Forum
6 answers
269 views
I thought I would share our solution for robust Kendo+Typescript+Requirejs support, in the hope that Telerik starts including this out of the box in Kendo.

THE PROBLEM
Currently the Kendo typescript definitions don't include any declarations of AMD modules for use with requirejs. While it is possible to work around this in a number of ways to at least get the require("<kendo file>") statements to emit into the javascript code, the fundamental issue is that the Typescript compiler is not aware of which kendo classes belong in which AMD module. This means that you can write typescript code that compiles fine, but does not actually work at run-time. For example:
import kendoData = require("kendo\kendo.data"); // I want to do something with data, emit require statement
var data = new kendo.data.ObservableObject()
kendo.bind("#target", data);

This will compile fine because as far as the compiler is concerned the entire kendo library is always loaded and global. However when you run the resultant javascript from the above code, it will fail because kendo.bind is not within the require chain of kendo.data.js.

This becomes very annoying because you are never 100% sure you are requiring the correct kendo modules actually needed for the code you write.

OUR SOLUTION
The solution we are using is to define our own kendo AMD module definitions, and have them explicitly re-export the named types from the kendo global scope out of the AMD module. Each AMD module only re-exports the kendo types that are actually contained within that modules kendo javascript file. For example in our new kendo.web.amd.d.ts file (which contains all the AMD module defs in one file) we have:
declare module "kendo/kendo.data" {
    module data {
        export import Datasource = kendo.data.DataSource;
        export import ObservableObject = kendo.data.ObservableObject;
    }
}

The compiler is now aware of kendo.data.js as a proper AMD module, and knows exactly which types are available out of it. The leading "kendo/" is required so that we can configure requirejs to map to the actual kendo library path. As long as we avoid referring to the global kendo module in our typescript code, we now guarantee that if code compiles, it will also be pulling in the correct modules at runtime. The original example now looks like this:
import kendoData = require("kendo\kendo.data");
import kendoBind = require("kendo\kendo.binder");
var data = new kendoData.data.ObservableObject();
kendoBind.bind("#target", data);

Note that we no longer reference the global "kendo" module, we only use types within the modules we have explicitly imported. Intellisense is smart enough to drop down all types available in the module, for example here typing "kendoData." will drop down everything available out of that AMD module.

A BETTER SOLUTION
The only problem with the above solution is that the global module is still available to the typescript compiler, so if you accidentally reference a type straight out of the global "kendo", you are back to the original problem where it will compile fine, but then fail at runtime. A better solution would be for Telerik to provide two versions of each definition file, ie

kendo.web.ts
kendo.web.amd.ts

The .amd version, rather than just declaring all types in the global kendo namespace, would declare each type within the actual named module that it resided in (with the leading "kendo/" to allow path remapping!!). Within our projects we could then choose to include only the kendo.web.amd file, which would enforce that no kendo types are available unless you import the associated module.

Marc
Top achievements
Rank 1
 answered on 28 Jul 2016
1 answer
2.2K+ views
I iterate through grid.items(). How can I check if items[i] is selected. Is it safe to check aria-selected attribute on tr when options.selectable is row or aria-selected attribute on td when options.selectable is cell?
Dimiter Topalov
Telerik team
 answered on 28 Jul 2016
1 answer
707 views
 Lets say i have a kendo dropdown like the following.
 
 var data = [
                        {text: "Item1", value:"1", type: "User"},
                        {text: "Item2", value:"2", type: "User"},
                        {text: "Item3", value:"3", type: "Group"}
                    ];

                    $("#dropdownlist").kendoDropDownList({
                        dataTextField: "text",
                        dataValueField: "value",
                        dataSource: data
                    });

Now, I would like to load glyphicon based on the type of the each item. In other words, glyphicon1 if item is of type  "user" and  glyphicon2 if item is of type "Group"

I know i can use the "template" to load icons with the items in the dropdown but how can i do it conditionally based on a property of the items?
Dimiter Topalov
Telerik team
 answered on 28 Jul 2016
1 answer
91 views

After upgrading to Kendo UI v2016.2.504, the shapes of diagrams can not be moved with the mouse.

If I simply replace kendo.all.js with our previous version (which was Kendo UI v2015.1.521), they can be moved with the mouse. and thats what our users want...

Can you help ?

Thank you in advance.

 

 

Misho
Telerik team
 answered on 28 Jul 2016
1 answer
1.5K+ views

We are doing filtering and sorting client side. We hook into the change event and filter out the results. All is well until the sort is done descending. The correct number of records are displayed but the records themselves are the wrong ones. It's like the indexing is wrong on the displayed records. Can someone point me at what to look at to figure his out. Thanks.

 

01.function filterButtonClicked(gridId) {
02.    var grid = $("#" + gridId.toLowerCase() + "Grid").data("kendoGrid");
03.    var filtertxt = $("#txt" + gridId + "Filter").val().trim().toLowerCase();
04.    $("#" + gridId.toLowerCase() + "Grid")
05.        .find("table > tbody > tr")
06.        .each(function (i) {
07.            var currentRow = $(this);
08.            var displayName = grid.dataSource.data()[i].DisplayName.toLowerCase();
09.            // See if filter should be applied
10.            console.log(filtertxt);
11.            console.log(displayName);
12.            if (displayName.indexOf(filtertxt) >= 0) {
13.                currentRow.show();
14.            } else {
15.                currentRow.hide();
16.            }
17.        });
18.}

And this is the grid event hook but the event is getting called just fine.

1.    ...
2.    dataBound: gridOnDataBound,
3.    change: filterButtonClicked('Available')
4.}).data("kendoGrid");

 

Boyan Dimitrov
Telerik team
 answered on 28 Jul 2016
13 answers
1.5K+ views
I've got a tree view with potentially thousands of nodes that may be up to 20 levels deep.  I am doing load on demand as well.  This is all working great so far.

I'm now working on a feature where the user would search for a node given the description and get back the path to the selected node from the root (an array of Id values).  The first two nodes (root and second level) are guaranteed to be there since I always start out with the root open.  It's when I search for and try to navigate to a node at level 3 or below that I am starting to have my main issues.

Here is the "success" function from the AJAX method used to get the "path from the root to the selected node"
function (result) { // success
    if (result.length > 0) {
        // add the leaf node since it is not included in the "path to the node"
        var nplus1 = result[result.length - 1].HierLevel + 1;
        var leafNode = { OrgId: parseFloat(id), HierLevel: nplus1 };
        result.push(leafNode);
        // get the tree view
        var treeview = $('#treeview').data('kendoTreeView');
        // collapse all nodes
        treeview.collapse(".k-item");
        // get the data source
        var dataSource = treeview.dataSource;
        $.each(result, function (idx, val) {
            var dataItem = dataSource.get(val.OrgId); // find item with OrgId value
            var node = treeview.findByUid(dataItem.uid); // find treeview item by uid
            treeview.expand(node);
            if (val.HierLevel === nplus1) {
                treeview.select(node);
            }
        });
    }
}

I realize there are some issues here - such as how to deal with the async nature of loading the next node (expanding level 2+) on demand but still continuing to iterate thru the array of "path to node" items.  In the example above, when I get (dataSource.get) the 3rd level item (that doesn't exist in the datasource), an error "Uncaught TypeError: Cannot read property 'length' of undefined" in kendo.all.min.js, line 11 (Kendo UI Complete v2013.2.918)

Also, the expand and select aren't working, but one thing at a time.

Any pointers in the right direction are appreciated.

Thanks,
--Ed
Alex Gyoshev
Telerik team
 answered on 28 Jul 2016
1 answer
434 views

hi guys, 

I'm trying to set a default value for all the cells of a specific index whenever a new row in created in the spreadsheet. 

I wanted to do this with the change event of the spreadsheet and basically do: get current selected cell position & go to my desired index on that row and add the default value. However i wasn't able to find how to get the selected's cell position in the change event function.

Another idea was to set a default value for my specific cell index with "sheets.rows.cells.value" but i see it needs a row index which in my case is dynamic.

 

Thanks a lot for the help

Boyan Dimitrov
Telerik team
 answered on 28 Jul 2016
1 answer
97 views
My company is working on a project where they are using Microsoft Dynamics AX7 as the platform. Dynamics doesn't currently support the addition of third party controls into their platform, though it does allow for extending existing controls or the creation of custom controls using other AX Native controls.

We have experimented with embedding a Kendo grid on an AX form with limited success. This is more due to our lack of knowledge of AX than issues with Kendo.

Does anyone have any experience integrating Telerik controls into the AX7 platform? Are there any plans to create controls that could be integrated with AX7?
Kiril Nikolov
Telerik team
 answered on 28 Jul 2016
4 answers
713 views
Hi, I'm looking for a way to catch when a user types in a value that is higher than the max of a numericTextBox before it gets trimmed down by the component. The point of this is to alert the user that they have entered invalid data and inform them of the max possible value.

For example, if I type 120 into a textbox with a max of 100, I would like to let the user know that they have gone over the max value.

Is there any way to handle such an event? I've already tried using the change method to no avail, as I am unable to access the original value typed into the textbox. The only thing I can think of is removing the max and min parameters on my numericTextBox and handling everything with a Kendo Validator, but this option seems pretty intensive for what seems like a relatively simple task.

Thanks for any help!
Mihail
Top achievements
Rank 1
 answered on 28 Jul 2016
5 answers
509 views
How to avoid temporary File upload while using Kendo().Upload() , Can we directly save to DB ?
Dimiter Madjarov
Telerik team
 answered on 28 Jul 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?