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);
}())
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);
}
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!
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
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!
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?
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(/\"\;/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.
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.
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 :(.