Telerik Forums
Kendo UI for jQuery Forum
5 answers
394 views
So I have a myViewModel.js that I read in. which has the datasource, but I doesn't seem to call destroy.
Also the kendo.data.ObservableObject.fn.init.apply(that, []);  confuses me.  I wish there were more mvvm examples that are read in from a js file.

in my html I got:
$("#dgGrid").kendoGrid({
      groupable: false,
      sortable: true,
 
      editable: "inline",
      columns: [
              {
                  field: "accountId",
                  title: "User #",
                  width: "50px"
 
              },
 
          {
              field: "currentAmt",
              title: "Amount",
              width: "100px"
 
          },
     { command: [{ name: "destroy", template: "<div class='k-button'><span class='k-icon k-delete'></span></div>" }], title: " ", width: 40 }
     
 
 
      ]
  });
<div id="dgGrid" data-role="grid" style="width:340px; font-size:9px; height:250px"
 
     data-bind="source: userAccountsDataSource">
    <style type="text/css">
        .k-grid tbody .k-button {
            min-width: 12px;
            width: 30px;
        }
    </style>
</div>

(function (global) {
    var FlossViewModel,
        app = global.app = global.app || {};
 
    FlossViewModel = kendo.data.ObservableObject.extend({
  
        acountId: "",
        accountNick: "",
        newbcId: "q",
        userId: "0",
        checkDate: "",
        errorMsg: "",
        accountsVis: true,
         
     
        userAccountsDataSource: "",
 
 
    
 
        refreshAccount: function(){
            this.populateAccounts();
 
        },
        populateAccounts: function(){
            var that = this;
 
           // kendo.data.ObservableObject.fn.init.apply(that, []);
            var dataSourceaa = new kendo.data.DataSource({
 
                transport: {
 
                    read: {
                                type: "GET",
                                dataType: "jsonp",
                                url: '/api/FlossAccount/'
                                    },
 
                    destroy: {
                        type: "DELETE",
                        url: function (options) {
                            return '/api/FlossAccount/1';
                        },
 
                        dataType: "jsonp",
                        data: {'' : '333'}, //i'm just putting any data for now
                        cache: false
 
 
 
                    },
                    parameterMap: function (options, operation) {
                        if (operation !== "read" && options.models) {
                            return { models: kendo.stringify(options.models) };
                        }
                    }
                },
 
                error: function (e) {
                    that.set("errorMsg", "Error: Check Connection ");
                    dataSourceaa.cancelChanges();
 
                }
            });
 
          that.set("userAccountsDataSource", dataSourceaa);
 
 
            dataSourceaa.read();
         //  this.set("userAccountsDataSource", dataSourceaa);
 
        },
   
         .....
 
    });
 
    app.flossService = {
        viewModel: new FlossViewModel()
    };
})(window);

Alexander Valchev
Telerik team
 answered on 23 May 2014
2 answers
239 views
When I set any of my events to include a RecurrenceRule, I suddenly can't double-click on any of the events without getting the javascript error:

Uncaught TypeError: Cannot read property 'isOccurrence' of undefined

What is causing this and how can I fix it?

I'm doing an ajax call to retrieve the data, then re-binding it to the Scheduler control.  Here is my code:

            // When the JSON comes back, it will capital letters like Title and Start.  The scheduler needs these lower case, so define the model.
            var dataSource = new kendo.data.SchedulerDataSource({
                data: response.Data,
                schema: {
                    model: {
                        id: "ID",
                        fields: {
                            ID: { type: "number" },
                            title: { field: "Title", defaultValue: "No title", validation: { required: true } },
                            start: { type: "date", field: "Start" },
                            end: { type: "date", field: "End" },
                            description: { field: "Description" },
                            recurrenceId: { from: "RecurrenceID" },
                            recurrenceRule: { from: "RecurrenceRule" },
                            recurrenceException: { from: "RecurrenceException" },
                            ownerId: { field: "OwnerID", defaultValue: 1 },
                            isAllDay: { type: "boolean", field: "IsAllDay" }
                        }
                    }
                }
            });

            scheduler.setDataSource(dataSource);

and here is the json that is being returned:

{"Success":true,"Data":[{"Id":69314,"EventType":"Event","Title":"Event 69314","Start":"\/Date(1400772600000)\/","StartTimezone":null,"End":"\/Date(1400785200000)\/","EndTimezone":null,"Description":null,"IsAllDay":false,"Recurrence":null,"RecurrenceRule":"FREQ=DAILY","RecurrenceException":null,"EventTitle":"Air duct cleaning","AssociatedWithType":"Job","AssociatedWithId":8225,"AssociatedWithName":"25854 Maclure","JobId":"25854","Color":"#991aae","Pending":false,"Completed":false,"BackgroundColor":"#c1e4ef","FontColor":"#ff0000","ResourceDisplay":"Abigail","Resources":[{"Id":299,"Name":"Abigail","Available":false,"IsDefaultChecked":false,"Type":null,"Color":null}],"EventDuration":210,"EventDurationWorkDayPixels":47,"MinutesBeforeWorkDayStart":90,"MinutesBeforeWorkDayStartPixels":20},{"Id":69312,"EventType":"Event","Title":"Event 69312","Start":"\/Date(1400414400000)\/","StartTimezone":null,"End":"\/Date(1400454000000)\/","EndTimezone":null,"Description":null,"IsAllDay":false,"Recurrence":null,"RecurrenceRule":null,"RecurrenceException":null,"EventTitle":"Air duct cleaning","AssociatedWithType":"Job","AssociatedWithId":22345,"AssociatedWithName":"a","JobId":"a","Color":"#FFC0CB","Pending":false,"Completed":false,"BackgroundColor":"#c1e4ef","FontColor":"#ff0000","ResourceDisplay":"Chelsea","Resources":[{"Id":2,"Name":"Chelsea","Available":false,"IsDefaultChecked":false,"Type":null,"Color":null}],"EventDuration":660,"EventDurationWorkDayPixels":147,"MinutesBeforeWorkDayStart":-120,"MinutesBeforeWorkDayStartPixels":-27}]}

Scott
Top achievements
Rank 1
 answered on 23 May 2014
2 answers
79 views
Hi,

I have several categories. The series value for some of the categories can be a lot larger than the values for other series.
Example:
[
    { type: "foo", count: 6589 },
    { type: "bar", count: 2 },
     ... more series
]

In the case of a pie chart, this results in the "bar" slice being very small. The problem is that I want to capture series click events. But, these small slices are unusable in that way.

Is there a way to configure bar, pie and similar charts to have these series with small values always take up some minimum space?
Josh
Top achievements
Rank 1
 answered on 23 May 2014
2 answers
133 views
I have 2 grids on my cshtml. The 'child' is inside a kend-tmpl template.
The nested grid is editable in a popup using an editor template.

Im wondering how do I pass the key of nested grid to the editor template?

The editor template's datasource action is dependent upon the parent key. When editing I can get the key, but only when adding new I am stuck.

Ive looked at 2 ways of doing this. one is with a field default.value on the grid's datasource.Model.Field. Two is on the grid edit event I assign the model's field the value after looking it up.

Option 1: The default value gets passed through but it seems I can only use simple types, hard coded like integers.
model.Field(i => i.PersonID).DefaultValue(222); THIS WORKS
model.Field(i => i.PersonID).DefaultValue("#=PersonKey#"); THIS fails on convert string to int.
model.Field(i => i.PersonID).DefaultValue(new { PersonID = "#=PersonKey#"  }); This fails on conversion from anon type


model.Field(i => i.PersonID).DefaultValue("#=PersonKey#");


Option 2: The grid edit javascript function hits and I want to execute this code before the editor template's data.read action is called.
function onEditRequest(e) {   
    var PersonID = $("#PersonID").val();
    //check if record is new
    if (e.model.isNew()) {
        //set the default value for StateID
        e.model.set("PersonID", PersonID);
    }
}
The problem is that this function above is not called before the editor template's function (dropdown list datasource .read action)
In fact when debugging in each function it will go back and forth (almost line by line) so there is no guarantee the edit is called before the datasource read (which requires the key)

Any ideas?
Petur Subev
Telerik team
 answered on 23 May 2014
2 answers
132 views
Hi 

I am trying to display a remote XML data in a bar chart. Below is my code. 

<script type="text/javascript">
        $(document).ready(function() {
            $("#chart").kendoChart({
                dataSource: {
                    transport: {
                        read: {
                            url: "asat.xml",
                            dataType: "xml"
                        }
                    },
                    schema: {
                      type: "xml",
                      data: "/cCRMGetForecastByStageResponse/ForecastStages/ForecastStage",
                      model: {
                        fields: {
                          opportunitycount: "opportunitycount/text()",
                          leadscount: "leadscount/text()",
                          description: "description/text()"
                        }
                      }
                    }         
                },
                title: {
                    text: "Forecast Count by Stage"
                },
                legend: {
                    position: "top"
                },
                seriesDefaults: {
                    type: "column"
                },
                series:
                [{
                    field: opportunitycount,
                    name: "Opportunities"
                }, {
                    field: leadscount,
                    name: "Leads"
                }],
                categoryAxis: {
                    field: "description",
                    labels: {
                        rotation: -90
                    },
                    majorGridLines: {
                        visible: false
                    }
                },
                valueAxis: {
                    labels: {
                        format: "N0"
                    },
                    majorUnit: 1,
                    line: {
                        visible: false
                    }
                },
                tooltip: {
                    visible: true,
                    format: "N0"
                }
            });    
        });
    </script>


My XML is as below,

<?xml version="1.0"?>
<cCRMGetForecastByStageResponse xmlns="http://www.pronto.net/crm/1.0">
  <ForecastStages>
    <ForecastStage>
      <description>Initial Stage</description>
      <opportunycount>2</opportuny-count>
      <opportunyamount>1256</opportuny-amount>
      <leadscount>0</leads-count>
      <leadsamount>0</leads-amount>
    </ForecastStage>
    <ForecastStage/>
    <ForecastStage>
      <description>First Stage</description>
      <opportunitycount>1</opportunitycount>
      <opportunyamount>100</opportuny-amount>
      <leadscount>1</leadscount>
      <leadsamount>80000</leads-amount>
    </ForecastStage>
  </ForecastStages>
</cCRMGetForecastByStageResponse >


When I run it, an error comes saying opportunitycount is not defined. 

When I use the same data in a json (without the schema section above), it works. 

Is there a way to directly bind XML elements in series section? 

Thanks in advance,
Ishan

PS: I personally think your example should cover XML data binding as well. Almost all examples are based on JSON.
Asat
Top achievements
Rank 1
 answered on 23 May 2014
1 answer
115 views
 I have a tree  like:
    
   - foo
        bar

when I selected the bar, I want to reset the name. How can i do .thanks
Kiril Nikolov
Telerik team
 answered on 23 May 2014
3 answers
266 views
Hi Experts,

I have found that in the demo of MultiSelect controller, when loading data, can show a little loading icon in the controller. I want to know if there are 2 APIs that I can invoke to show loading and close loading. Because I implement the data request with ajax in the page, after this ajax finish I will fill data in the MultiSelect controller, but during the ajax request data, I want the MultiSelect controller show loading.
Kiril Nikolov
Telerik team
 answered on 23 May 2014
4 answers
243 views
Hello

I was trying evaluate the scheduler widget in appbuilder and found very interesting thing. I created three views and the third view contains the scheduler div which got initialized on data-init event of that view.

Everything worked very well before I tried to dig deeper and wanted to do something on click of save button under the event view. On save I tried to navigate to another view  which i successfully able to but when i come back again to scheduler, I found everything got freeze in scheduler and scheduler becomes unselectable.

I was thinking to reinitialize scheduler whenever I navigate to that view. Please let me know the best possible solution in this case.

I have created a sample project. Please have a look at the following URL:

http://trykendoui.telerik.com/ataX

In order to reproduce the issue, open Drawer, click scheduler, navigate to event details, there is one button " Go to Home" click that and again try to come back on scheduler using drawer menu.




test
Top achievements
Rank 1
 answered on 23 May 2014
4 answers
331 views
Hi, 

I have following code,

$("#activities").kendoScheduler({
date: new Date("2014/5/19"),
startTime: new Date("2014/5/19 00:00 AM"),
endTime: new Date("2014/5/19 08:00 PM"),
views: [
{ type: "day", selected: true },
"week",
"month"
],
editable: false,
timezone: "Etc/UTC",
dataSource: {
batch: true,
transport: {
read: {
type: 'POST',
contentType: "text/xml",
url: "https:///xxx:8443/xxx/rest/xxxapp/api/xxxGetActivities",
processData: false,
dataType: "xml",
headers: { 'X-xxx-Token': '8430694659957936307' }
},
parameterMap: function() {
return '<?xml version="1.0" encoding="UTF-8" standalone="no"?><xxxGetActivitiesRequest xmlns="http://www.xxx.net/xxx/1.0"><RecordLimit>30</RecordLimit><RequestFields><Activities><Activity><ActivityNo/><AccountName/><AccountNumber/><ContactFullName/><ContactName/><ContactNameSequence/><ActivitySubject/><ActivityPriority/><ActivityPriorityCode/><ActivityText1/><ActivityText2/><ActivityText3/><ActivityStatus/><ActivityStatusCode/><ActionDate/><ActionTime/><ActionDateTime/><EndDate/><Location/><ActivityResolution/><ActivityResolutionCode/><ActivityType/><ActivityTypeCode/><LeadOpportunityNo/><LeadOpportunityTypeCode/><LeadOpportunityDetails/></Activity></Activities></RequestFields><Filters><ActivityStatusCode><Like>%</Like><NotLike>F</NotLike><NotLike>C</NotLike></ActivityStatusCode><ActionDate><Range><From>D-30</From><To>D+30</To></Range></ActionDate></Filters></xxxGetActivitiesRequest>'
}
},
schema: {
model: {
id: "activityNo",
fields: {
activityNo: { from: "ActivityNo", type: "number" },
title: { from: "ActivitySubject", defaultValue: "No title", validation: { required: true } },
start: { type: "date", from: "ActionDate" , format: "{0:dd-MMM-yyyy}"},
end: { type: "date", from: "EndDate", format: "{0:dd-MMM-yyyy}" },
atendees: { from: "ContactFullName", nullable: true },
startTimezone: { from: "StartTimezone",nullable: true  },
endTimezone: { from: "EndTimezone",nullable: true  },
description: { from: "Description",nullable: true  },
recurrenceId: { from: "RecurrenceID",nullable: true  },
recurrenceRule: { from: "RecurrenceRule",nullable: true  },
recurrenceException: { from: "RecurrenceException",nullable: true  },
roomId: { from: "RoomID", nullable: true },
isAllDay: { type: "boolean", from: "IsAllDay" , nullable: true }
}
}
}
}
}); 


Even though I can see the call is made to the web service and correct data is downloaded, no activities are not displayed in the scheduler as I expect. Few questions,

1. In the service I don't have all the schema models. So I have put dummy from fields with nullable true. is that correct
2. Dates are passed back from the web service in dd-MMM-yyyy format (ex: 14-May-2014). How can I map it to underlying dates in Kendo (is it automatically done?). I am not talking about visual aspects here but background mapping. 
3. Is there anything else wrong in my code? 


You help is highly appreciated.
Asat


Vladimir Iliev
Telerik team
 answered on 23 May 2014
4 answers
1.0K+ views
Is there a demo showing the exact same functionality at this link http://demos.kendoui.com/web/grid/remote-data.html 
using JSON instead of ODATA?

I would like to implement this in ASP.NET MVC 3, WCF, and EF 4.3 using JSON
Garry
Top achievements
Rank 2
Veteran
 answered on 23 May 2014
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
MultiColumnComboBox
Chat
DateRangePicker
Dialog
Checkbox
Timeline
Drawer
DateInput
ProgressBar
MediaPlayer
ImageEditor
TextBox
OrgChart
Effects
Accessibility
PivotGridV2
ScrollView
BulletChart
Licensing
QRCode
ResponsivePanel
Switch
Wizard
CheckBoxGroup
TextArea
Barcode
Breadcrumb
Collapsible
Localization
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
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?