Telerik Forums
Kendo UI for jQuery Forum
2 answers
227 views
I am working to get KendoUI, Typescript, and RequireJS to work together.  I have a version that is working but I would like advice on improving it.

Attached is my simple example in a Visual Studio 2013 RC project.  (UpdatedKendoUITypeScriptRequireJS.zip)

I have searched the web exhaustively but have not found anyone that has an example of the combination of KendoUI, Typescript, and RequireJS, but I may have missed it. :-).  

What I did to make it work was create a file called kendo.custom.d.ts.  In this file I put the following declarations for the two KendoUI widgets that I am using in my simple example: 
declare module "k/kendo.autocomplete.min" {
    export var load;
}
 
declare module "k/kendo.menu.min" {
    export var load;
}
I also included the kendo.all.d.ts file.

In my JavaScript I configured RequireJS like the following:
<script type="text/javascript">
 
    require.config({
        paths: {
            app: '/Scripts/app',
            k: 'http://cdn.kendostatic.com/2013.2.716/js'
        }
    });
 
    require(['app/index'],
            function (i) {
                new i.index();
            });
</script>
In the TypeScript file, index.ts I brought in the dependencies like the following:
import kendoConstant = require('app/kendoConstant');
import kendoMenuScript = require('k/kendo.menu.min');
import kendoAutoCompleteScript = require("k/kendo.autocomplete.min");
 
export class index {
    private _menuElement: JQuery;
    private _searchButtonElement: JQuery;
    private _searchBoxElement: JQuery;
 
    private _searchDataSource: kendo.data.DataSource;
    private _searchBox: kendo.ui.AutoComplete;
 
    private _searchAutocompleteMinLength: number;
 
    constructor() {
        kendoMenuScript;  //necessary reference so the k/kendo.menu.min will be in the generated require statement
        kendoAutoCompleteScript; //necessary reference so the k/kendo.autocomplete.min will be in the generated require statement
 
        this._searchAutocompleteMinLength = 3;
       
        this._menuElement = $("#menu")
        this._searchBoxElement = $("#searchBox");
        this._searchButtonElement = $("#searchButton");
 
        this._menuElement.kendoMenu();
        this._menuElement.show();
 
        this._searchDataSource = this.createSearchDataSource();
        this._searchBox = this.createAutoComplete();
 
        this._searchBoxElement.keydown((e) => {
            if (e.which == kendo.keys.ENTER) {
                this.processSearch();
            }
        });
         
        this._searchButtonElement.click(() => this.processSearch());
    }
 
    private createSearchDataSource(): kendo.data.DataSource {
        return new kendo.data.DataSource({
            data: [
                { "id": 1, "name": "John Doe" },
                { "id": 2, "name": "John Smith" },
                { "id": 3, "name": "Jane Doe" },
                { "id": 4, "name": "Johnny Appleseed" },
                { "id": 5, "name": "Joan Maryland" },
                { "id": 6, "name": "Johan Brown" }
            ]
        });
    }
 
    private createAutoComplete(): kendo.ui.AutoComplete {
 
        return this._searchBoxElement.kendoAutoComplete({
            dataSource: this._searchDataSource,
            placeholder: "Search...",
            minLength: this._searchAutocompleteMinLength,
            filter: "startswith",
            dataTextField: "name",
            suggest: true,
        }).data(kendoConstant.kendoAutoComplete);
 
    }
 
    private processSearch() {
        var value = this._searchBox.value();
        if (value != "") {
            alert(value + " would be searched for...");
        }
    }
}

You can see I import the kendoMenuScript and kendoAutoCompleteScript with a require of the path of the actual Kendo file that contains the JavaScript for the widget.  In the TypeScript file I make add a call to kendoMenuScript and kendoAutoCompleteScript so that TypeScript will add them to the "require" that it will generate, so that the actual Kendo JavaScript files will be pulled in.

Is there a better way to do this?

Kerry
Top achievements
Rank 1
 answered on 30 Sep 2013
1 answer
959 views
I have a datagrid of numbers that I format as a number, but if the number if 0 or null, I want don't want anything displayed.

How do I do this with KendoUI?

Also is there an easier way to make all numbers align to the right rather than injecting a style for the column?

Here is the grid that I am using:

@(Html.Kendo().Grid<KendoWithChart.Models.Report_Result>()
            .Name("grid")
            .BindTo((IEnumerable<KendoWithChart.Models.Report_Result>)ViewBag.SomeData)
      
            .Columns(columns =>
            {
                columns.Bound(p => p.DESCRIPTION).Title("Description").ClientTemplate("# if( DESCRIPTION == 'Total IP') { # <strong>#: DESCRIPTION#</strong> # } else if( DESCRIPTION == 'Target Blended Liability') { # <strong>#: DESCRIPTION #</strong> # } else { # #: DESCRIPTION # # } #");
                columns.Bound(p => p.DV01).Format("{0:n}").HtmlAttributes(new { style = "text-align:right" });
            })
      
            
            .Sortable() // Enable sorting
            .DataSource(dataSource => dataSource.Ajax()
                .Group(group => group.Add(p => p.Type))
                .ServerOperation(false)
                
            )
        )

Atanas Korchev
Telerik team
 answered on 30 Sep 2013
3 answers
80 views
Hi!

I am using "Group Field" and my bubbles size not respect the values. The bubbles are all the same size.
http://jsbin.com/onabop/44/edit?html,css,output
Alexander Popov
Telerik team
 answered on 30 Sep 2013
1 answer
216 views
I just want to change the height of the views
    views: [
            {
              type: "day",
                majorTick: 75, // a major tick represents 120 minutes (2 hours)
                minorTickCount: 3 // display one time slot per major tick
                cellHeight: 10 //Someting Like that
    
            },

Right now, the height is 20

Someting like eventHeight: 20 //for the month view but for the day view

Vladimir Iliev
Telerik team
 answered on 30 Sep 2013
16 answers
666 views
Hello,

I can't ge the autocomplete control work in the mvc grid. I created a new Display and Editor template to bind my person object (login and name property). The display template contains a simple Html.DisplayFor control to output the name of the person. Works perfect.

The Editor template contains an autocomplete bound to a server side data source, which populates the autocomplete controls with persons from a data store. So far so good.
Now the problem: When I leave the cell edit mode (with the autocomplete editor shown), a javascript error is thrown in "kendo.web.js". The error pops up in the following line:

that._unbindDataSource();

The error Message:
"Microsoft JScript runtime error: Object doesn't support property or method '_unbindDataSource'".

Any ideas how to get the autocomplete control work together with the grid?
Leon
Top achievements
Rank 1
 answered on 30 Sep 2013
1 answer
163 views
Starting with an Icenium project in Visual Studio I just wanted to add a timer to the location screen to refresh the map every 60 seconds. However no matter where I put the timer it only fires once it seems that due to how the JS code is laid out/implemented the timer is going out of scope and so is only firing once when it is initialised/

What would be the right way to implement a timer on this tab ?

Thanks

Greg
Steve
Telerik team
 answered on 30 Sep 2013
3 answers
459 views
If I use the data from the web service, edit and save.. Everything works great. If I use the code below I get the following error:
Uncaught TypeError: Object #<Object> has no method 'call'
Full Error:
Uncaught 
TypeError: Object #<Object> has no method 'call'    kendo.all.js:5521
(anonymous function)   kendo.all.js:5521
jQuery.extend.Deferred   jquery-1.8.2.js:1182
Observable.extend._promise   kendo.all.js:5520
Observable.extend._send   kendo.all.js:5548
Observable.extend.sync   kendo.all.js:5384
Widget.extend.saveRow   kendo.all.js:16577
(anonymous function)   kendo.all.js:16399
jQuery.event.dispatch  jquery-1.8.2.js:3063
jQuery.event.add.elemData.handle.eventHandle   jquery-1.8.2.js:2681

following code:

    <script src="Scripts/KendoUI/jquery-1.8.2.js"></script>
    <script src="Scripts/KendoUI/kendo.all.js"></script>

$(document).ready(createkendo = function () {

var myData = [{"Id":1,"StudyName":"StudyName123","Subjid":"1","MatchId":"1","MatchSources":"1","ArgusCaseNum":"1","Field":"1","ArgusValue":"1","EdcValue":"1","ValuesMatch":"Y","Status":"1","DmComments":"comments, comments","PvComments":"333","DateCreated":"2013-09-26T06:57:07"},{"Id":2,"StudyName":"StudyName555","Subjid":"test","MatchId":"test","MatchSources":"test","ArgusCaseNum":"test","Field":"test","ArgusValue":"test","EdcValue":"test","ValuesMatch":"Y","Status":"test","DmComments":"asdfasdf","PvComments":"222","DateCreated":"0001-01-01T00:00:00"},{"Id":4,"StudyName":"asdfasdf","Subjid":"test","MatchId":"test","MatchSources":"test","ArgusCaseNum":"test","Field":"test","ArgusValue":"test","EdcValue":"test","ValuesMatch":"Y","Status":"test","DmComments":"asdf","PvComments":null,"DateCreated":"0001-01-01T00:00:00"}];
var crudServiceBaseUrl = "http://dev-webapp1.infinitypharm1.com/Argus.WebServices/api",
dataSource = new kendo.data.DataSource({
                            serverPaging: false,
                            serverFiltering: false,
                            serverSorting: false,
                            pageSize: 20,
                            schema: {
                                model: {
                                    id: "Id",
                                    fields: {
                                        StudyName: { type: "string" },
                                        DmComments: { type: "string" },
                                        PvComments: { type: "string" }
                                    }
                                }
                            },
                            batch: false,
                            transport: {
                                create: {
                                    url: crudServiceBaseUrl + "/argus",
                                    contentType: "application/json",
                                    type: "POST"
                                },
/*
                                read: {
                                    url: crudServiceBaseUrl + "/argus",
                                    contentType: "application/json",
                                    success: function(result) {
            options.success(result);
         }
                                },
                                */

read: function (options) {
options.success(localData); // where data is the local data array
},

update: {
                                    url: function (entity) {
                                        return crudServiceBaseUrl + "/argus/" + entity.Id;
                                    },
                                    contentType: "application/json",
                                    type: "PUT"
                                },
                                destroy: {
                                    url: function (entity) {
                                        return crudServiceBaseUrl + "/argus/" + entity.Id;
                                    },
                                    contentType: "application/json",
                                    type: "DELETE"
                                },
                                parameterMap: function (data, operation) {
                                    return JSON.stringify(data);
                                }
                            }
                        });

                    $("#grid").kendoGrid({
                        height: 600,
                        columns: [
                            { field: "StudyName", title: "Study Name" },
                            { field: "DmComments", title: "DM Comments" },
                            { field: "PvComments", title: "PV Comments" },
                            //{ command: "destroy", title: "Delete", width: "110px" }
                            { command: ["edit", "destroy"], title: "&nbsp;", width: "172px" }
                        ],
                        pageable: true,
                        sortable: true,
                        filterable: true,
                        editable: "inline", //true, // enable editing
                        //toolbar: ["create", "save", "cancel"], // specify toolbar commands
                        toolbar: ["create"],
dataSource: dataSource
                    });


});

Alexander Valchev
Telerik team
 answered on 30 Sep 2013
8 answers
126 views
Hi,

I'm writing a phonegap (3.0) app with Kendo UI Mobile.
I need to load 'remote' views from a web service. I know a remote view under phonegap is just another file on the local filesystem, which is not what I want.

I'm currently exploring using AJAX to request a view and insert it into the DOM, but when I do this I lose my application layout (header title and tabbar footer).
Do you have any information on the best practice for this use case?

I've got loads more information and different techniques I've tried, but will save all that unless it's helpful.

Thanks,
Robin
Kiril Nikolov
Telerik team
 answered on 30 Sep 2013
3 answers
445 views
I would like the tooltip to temporarily show when you hover over the target (and then disappear when you move mouse away)... but I would like the tooltip to stay when you click on the target (then go away when you click on the target again).

I have figured out how to do both of the above but I can't figure out how to combine them so the same target can use both behaviors.

Thanks
Alexander Popov
Telerik team
 answered on 30 Sep 2013
1 answer
35 views
Is there a page or list i can access on this forum that shows all the posts that I have either started or posted on?  Furthermore, is there a way I can "subscribe" to a thread so that I can get emails whenever there is activity on that thread?

Thanks
Sebastian
Telerik team
 answered on 30 Sep 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?