Telerik Forums
Kendo UI for jQuery Forum
1 answer
603 views

I've created 2 viewmodel with typescript, like mentioned here.
Both viewmodels have their own properties an functions. 

Now i want to load the viewmodel data from a json object comming from an ajax request.
I found a thread where this is done by $.extend which works quite good for data.
But how can i extend the nested viewmodel wth data and keep their functions?

Like in the example below "RoomOffer1ViewModel" does'nt have a function "bar" after $.extend

class Offers1ViewModel extends kendo.data.ObservableObject {
    RoomOffers: Array<RoomOffer1ViewModel>;
 
    constructor() {
        super();
        super.init(this);
        this.RoomOffers = [];
    }
 
    foo() {
        // do something
    }
}
 
class RoomOffer1ViewModel extends kendo.data.ObservableObject {
    Property1: string;
    Property2: number;
 
    constructor() {
        super();
        super.init(this);
    }
 
    bar() {
        // do something for "RoomOffer1ViewModel"
    }
}
 
(function () {
    // imagine the data below comes from an ajax request
    var jsonFromServer = {
        RoomOffer: [
            { Property1: "some", Property2: 1 },
            { Property1: "data", Property2: 2 },
            { Property1: "from", Property2: 3 },
            { Property1: "server", Property2: 4 }
        ]
    }
 
    var myViewModel = new Offers1ViewModel();
 
    $.extend(true, myViewModel, kendo.observable(jsonFromServer));
 
    kendo.bind($("body"), myViewModel);
}())

Martin
Telerik team
 answered on 24 Mar 2017
5 answers
1.3K+ views

I'm totally stuck

I have a simple dropdownlist 

<input class="span-full" data-role="dropdownlist" data-bind="events: {open: getProps }, value: '+ __cols[n].name +' ">

That I want to tie to a open event

getProps: function(e){
             console.log(e.sender);
}

When I click on the dropdown list I need to find out it's id or value is? How do I do that?

Something like?

getProps: function(e){
            // Find out whom I am

             console.log("Hello me" + value);
}

 

Ivan Danchev
Telerik team
 answered on 24 Mar 2017
1 answer
195 views

UI Ref : http://demos.telerik.com/kendo-ui/grid/editing

Service Ref: https://github.com/telerik/kendo-ui-demos-service

 

Hi, 

I have looked at this implementation for KendoUI batch editing but the service end doesn't work with Web API. As the type of controller used in Web API is different than one used in MVC controller. So, this: DeserializeObject<IEnumerable<ProductModel>>("models"); doesn't work in Web API. Do you have any solution for this. An urgent response would be appreciated.

Thx!

Boyan Dimitrov
Telerik team
 answered on 24 Mar 2017
1 answer
431 views

Hi,

I have a treeview and would like users to be able to add a new item to the treeview. When the new item is added I would like to have an AutoComplete field they can type the new node name into and use server-side filtering to retrieve the available values. 

 

How can I do this?

 

Thanks in advance

 

Matt

Ianko
Telerik team
 answered on 24 Mar 2017
8 answers
956 views

When the user changes the spreadsheet, I use the onchange method to run certain validations. Is there any way to determine which key(s) the user has pressed? I'm interested in keys such as delete and backspace.

Thanks!

Marc
Top achievements
Rank 1
 answered on 24 Mar 2017
3 answers
220 views

My cancel event in my scheduler is like so:

 

cancel: function(e){
                                console.log('Cancelling');
                            console.log(e); 
                                console.log(e.event.ownerId[0].value);
                                console.log(e);
                                if(e.event.id != '0'){
                                    e.sender.dataSource.sync();
                                    //e.sender.dataSource.read();
                                }
                            },

 

The only way I was able to get the scheduler to work somewhat properly is by calling dataSource sync in the cancel method because  before doing that, if you pressed cancel, the data structure of the event was altered and if you tried to re-open that event, it threw an error with my kendo multi-selects inside the edit/create window. However, by calling sync, the scheduler refreshes its data when you cancel and it all goes back to the way it should be.

My issue though... is that when I press cancel and it does its sync, it triggers the update method. So it basically has the same functionality as the save event because it goes through update and alters the data of the event if anything was changed and doesn't actually 'cancel'

I am wondering how I might prevent it from running update when cancel is pressed? And what determines if update CRUD operation is ran? Like I know that create gets triggered when the ID of the event is the default id specified in the schema, but not sure what determines if update should go or not. Is that the dirty bit of the event?

Ianko
Telerik team
 answered on 24 Mar 2017
4 answers
470 views

I am wondering how I might update the scheduler in the databinding event? When I try to call the dataSource read or just refresh the view, it goes into a continuous loop of datasource reading then scheduler databinding and nothing actually gets displayed in the scheduler.

 

My purpose for this is I am trying to filter events based on the start and end date of the current view because I am dealing with potentially thousands and thousands of events. 

 

My databinding event for the scheduler is:

dataBinding: function(e){
                            console.log(e);
                                console.log(e.sender.view());
                                console.log(e.sender.view().startDate());
                                console.log(e.sender.view().endDate());
                                console.log(e.sender.dataSource.data());
                                if(e.action === 'rebind'){
                                console.log('Rebinding data to scheduler!');  
                                    Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.CalendarData.getCurrentViewEvents}', e.sender.view().startDate(), e.sender.view().endDate(), '{!fieldSetMap}', function(result, event){
                                result = result.replace(/\&quot\;/g, '"');
                                    result = result.replace(/\#39\;/g, '\'');
                                    var resultArray = JSON.parse(result);
                                    console.log(resultArray);
                                        var correctedResults = getNewEvents(resultArray);
                                        console.log(correctedResults);
                                        eventData = correctedResults;
                                        //e.sender.dataSource.data(eventData);
                                        //scheduler.view(scheduler.view().name);
                                        
                                });
                                }
                            },

 

It gets tricky trying to update and refresh the eventData (which needs to go to the dataSource read operation because that is all my events) dealing with the remote action, which happens asynchronously, thus it would be ideal to refresh inside the remote action method callback in the dataBinding event function. But yeah, doing so as I have tried just gives me the never-ending loop of dataBinding/reading.

I am grabbing events from a database then storing them locally in eventData, I know there are remote data examples of server filtering based on the start and end date of the current view, but those do not help in my situation with local data.

Ianko
Telerik team
 answered on 24 Mar 2017
7 answers
1.2K+ views

I'm getting the following console error when trying to manually export a grid to Excel:

"Uncaught Error: This method has been removed in JSZip 3.0, please check the upgrade guide."

Code to trigger export:

  function exportGrid() {
        var grid = $("#coingrid").data("kendoGrid");
        grid.saveAsExcel();
  }

Should I revert to a 2.x version of JSZip, is there a work-around, or am I doing something wrong (most probable answer)? I'm using 2016.2 release of UI. Thanks.

Morten
Top achievements
Rank 2
Iron
Iron
Iron
 answered on 23 Mar 2017
1 answer
131 views

Kendo UI Bower Issue:

Package;
https://bower.telerik.com/bower-kendo-ui.git#~2017.1.321

File;
kendo-ui\styles\kendo.common.min.css

Issue;
Invalid selector:

.k-i-tri-state-$1 $2

---

This unfortunately breaks my entire project as it no longer builds :(.

Stefan
Telerik team
 answered on 23 Mar 2017
5 answers
1.7K+ views
Hello!

I have a kendo dropdownlist and a template in it that contains a textbox, but I find the existing dropdownlist events interfere with the textbox.

A pretty rough, yet fully functional, fiddle here: http://dojo.telerik.com/AripU

If you click on the "edit" image, you get a textbox but you are unable to click into it. I have managed to focus but the click is still being ignored.

I was told that b cannot be solved because the widget handles the "mousedown" event in order to keep the focus in the wrapper. Specifically "the widget controls the focus of the wrapper and popup element very restrictively in order to ensure the correct "change" event order when widget is blurred. That is why placing an input element inside the item is not supported. "I wonder if there is a way to override the mousedownn event?

I am keen to somehow work around this, rather than re-doing the whole thing using a grid so any creative solutions that can help me focus the textbox are very welcome.

Thanks
Nencho
Telerik team
 answered on 23 Mar 2017
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?