Telerik Forums
Kendo UI for jQuery Forum
1 answer
142 views

I'm trying to get Gantt working. I've configured it to use server to perform read, create and update. It loads events correctly and displays them on screen. I can update them just  fine.

However when I try to create new event, I get CreateEvent method called, I create event on server side, fill in all data, initialize Id field and send it back to server, just as required in documentation and done in demo code. When I try to update this newly created event I get new Create event being called, instead of update.

I assume that this is because UI does not store Id I've returned from server correctly. Even though I return element with Id = 9, I can see in kedo dataSource.data() that one of the elements have Id = 0.

 

What am I doing wrong?

public ActionResult CreateEvent([DataSourceRequest] DataSourceRequest request, EventVm @event)
        {
            var tm = new ProjectTimelineVm();
            tm.Events.Add(@event);
            @event.Id = tm.Events.Max(e => e.Id) + 1;
            @event.Start = DateTime.Parse(Request.Form["Start"], System.Globalization.CultureInfo.InvariantCulture);
            @event.End = DateTime.Parse(Request.Form["End"], System.Globalization.CultureInfo.InvariantCulture);
            @event.OrderId = @event.Id;
            @event.Expanded = false;
            @event.Summary = false;
            return Json(new[] { @event }.ToDataSourceResult(request, ModelState));
        }

 

and client side configuration (note that EventVm has Id property and Id property is expected by model configuration, after page reload newly added event will work fine):

var gantt;
$(function () {
    gantt = $("#timelineGantt").kendoGantt({
        columns: [
            { field: "Id", title: "ID", sortable: true },
            { field: "title", title: "Title", sortable: true },
            { field: "start", title: "Start", format: "{0: yyyy-MM-dd hh:mm:ss}", sortable: true },
            { field: "end", title: "End", format: "{0: yyyy-MM-dd hh:mm:ss}", sortable: true }],
        snap: true,
        height: 500,
        showWorkDays: false,
        showWorkHours: false,
        views: [
            { type: "day" },
            { type: "week", selected: true },
            { type: "month" }],
        dataSource: {
            type: (function () {
                if (kendo.data.transports['aspnetmvc-ajax']) {
                    return 'aspnetmvc-ajax';
                } else {
                    throw new Error('The kendo.aspnetmvc.min.js script is not included.');
                }
            })(),
            transport: {
                read: { url: "/Record/Project/ReadEvent" },
                prefix: "",
                update: { url: "/Record/Project/UpdateEvent" },
                create: { url: "/Record/Project/CreateEvent" }
            },
            schema: {
                data: "Data",
                total: "Total",
                errors: "Errors",
                model: {
                    id: "Id",
                    fields: {
                        Id: { type: "number" },
                        parentId: { from: "ParentId", type: "number", defaultValue: null },
                        orderId: { from: "OrderId", type: "number" },
                        percentComplete: { from: "PercentComplete", type: "number" },
                        start: { from: "Start", type: "date", defaultValue: new Date(2016, 3, 25, 14, 42, 36, 959) },
                        end: { from: "End", type: "date", defaultValue: new Date(2016, 3, 25, 14, 42, 36, 959) },
                        title: { from: "Title", type: "string" },
                        summary: { from: "Summary", type: "boolean", defaultValue: false },
                        expanded: { from: "Expanded", type: "boolean", defaultValue: false }
                    }
                }
            },
        },
        dependencies: {
            type: (function () {
                if (kendo.data.transports['aspnetmvc-ajax']) {
                    return 'aspnetmvc-ajax';
                } else {
                    throw new Error('The kendo.aspnetmvc.min.js script is not included.');
                }
            })(),
            transport: {
                read: { url: "" },
                prefix: ""
            },
            schema: {
                data: "Data", "total": "Total",
                errors: "Errors",
                model: {
                    fields: {
                        Type: { type: "number" },
                        DependencyID: { type: "number" },
                        PredecessorID: { type: "number" },
                        SuccessorID: { type: "number" }
                    }
                }
            },
            data: {
                Data: [],
                Total: 0,
                AggregateResults: null
            }
        }
    }).data("kendoGantt");
});

Hristo Valyavicharski
Telerik team
 answered on 27 Apr 2016
1 answer
150 views

Hi,

I was trying to create a angular stock chart with multiple series but no data/series displayed on chart.  Here is the html and java script code.

Am I missing something in chart options ? Please help.

 

Html: 

<div kendo-stock-chart k-options="chartOptions" style="height:400px; width:870px;" ></div>

 

$scope.chartOptions = {
                             dateField: "DateTime",
                             valueAxis: [{
                                 labels: {
                                     format: {}
                                 }
                             }],
                             seriesDefaults: {
                                 type: "line",
                                 style: "smooth"
                             },
                             series: [{
                                 type: "line",
                                 style: "smooth",
                                 field: "KPIVALUE",
                                 name: "Jan 11 2014 12:00AM",
                                 tooltip: {
                                     visible: "true",
                                     template: "#=DateTime#-#=KPIVALUE#"
                                 },
                                 data: [{
                                     DateTime: "2014-01-11T00:00:00.000Z",
                                     DateTimeTicks: "1391212800000",
                                     KPINAME: "percent11",
                                     KPIVALUE: 99.904454,
                                     SeriesName: "Jan 11 2014 12:00AM"
                                 }, {
                                     DateTime: "2014-01-11T00:15:00.000Z",
                                     DateTimeTicks: "1391213700000",
                                     KPINAME: "percent11",
                                     KPIVALUE: 99.900868,
                                     SeriesName: "Jan 11 2014 12:00AM"
                                 }, {
                                     DateTime: "2014-01-11T00:30:00.000Z",
                                     DateTimeTicks: "1391214600000",
                                     KPINAME: "percent11",
                                     KPIVALUE: 99.861033,
                                     SeriesName: "Jan 11 2014 12:00AM"
                                 }, {
                                     DateTime: "2014-01-11T00:45:00.000Z",
                                     DateTimeTicks: "1391215500000",
                                     KPINAME: "percent11",
                                     KPIVALUE: 99.906269,
                                     SeriesName: "Jan 11 2014 12:00AM"
                                 }, {
                                     DateTime: "2014-01-11T01:00:00.000Z",
                                     DateTimeTicks: "1391216400000",
                                     KPINAME: "percent11",
                                     KPIVALUE: 99.91746,
                                     SeriesName: "Jan 11 2014 12:00AM"
                                 }]
                             }]
                         }

 

Daniel
Telerik team
 answered on 27 Apr 2016
3 answers
369 views
I am trying to get the AutoComplete control to work with a WCF method that takes in parameters, I did get the autocomplete control to work with a wcf method that does not have any parameters, but when I try to pass in parameters it won't work. My code is below:

    [ServiceContract]
    public interface IShippers
    {
        [OperationContract]
        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)]
        IEnumerable<Company> QueryDatabase(string columns, string table, string whereClause);

        [OperationContract]
        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)]
        IEnumerable<Company> GetShippers();
    }

    [DataContract]
    public class Company
    {
        public Company(string id, string name)
        {
            Id = id;
            Name = name;
        }

        [DataMember]
        public string Id { get; set; }

        [DataMember]
        public string Name { get; set; }
    }

   [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class Shippers : IShippers
    {
        public IEnumerable<Company> QueryDatabase(string columns, string table, string whereClause)
        {
            List<Company> shippers = new List<Company>();

            try
            {
                var sql = string.Concat("select ", columns, " from ", table, " where ", whereClause);

                var drSql = ExecuteSql(sql);

                while (drSql.Read())
                {
                    shippers.Add(new Company(drSql.GetString(1), drSql.GetString(0)));
                }

                drSql.Close();

                return shippers;
            }
            catch (Exception ex)
            {
                var message = ex.Message;
                return null;
            }
        }

        private SqlDataReader ExecuteSql(string sql, bool useForXml = false)
        {
            const string connectionString = "Server=CLE-BWRENN;Database=TrucoCompany;Trusted_Connection=True;";

            if (useForXml)
                sql = string.Concat(sql, "FOR XML");

            SqlConnection cnSql = new SqlConnection(connectionString);
            cnSql.Open();

            SqlCommand cmSql = new SqlCommand(sql, cnSql);
            SqlDataReader drSql = cmSql.ExecuteReader(CommandBehavior.CloseConnection);

            return drSql;
        }

        public IEnumerable<Company> GetShippers()
        {
            List<Company> shippers = new List<Company>();

            var drSql = ExecuteSql("select cmp_name, cmp_id from company where cmp_shipper = 'y'");

            while (drSql.Read())
            {
                shippers.Add(new Company(drSql.GetString(1), drSql.GetString(0)));
            }

            drSql.Close();

            return shippers;
        }
    }

 <div id="AutoCompleteTest" class="k-content">
        <div id="Shipper">
            <input id="input" />
            <div class="hint">type shipper</div>
        </div>

        <script type="text/javascript">

            $(document).ready(function () {
                //$.ajax({
                //    type: "post",
                //    url: "http://localhost/WCFTest/Service1.svc/QueryDatabase",
                //    data: '{"columns":"cmp_name,cmp_id", "table":"company", "whereClause":"cmp_shipper = \'y\'"}',
                //    dataType: "json",
                //    contentType: "application/json; charset=utf-8",
                //    success: function(result) {
                //        debugger;
                //    },
                //    error: function (result) {
                //        debugger;
                //    }
                //});

                $("#input").kendoAutoComplete({
                    dataTextField: "Name",
                    template: "<span><b>${ data.Name }</b></span>&nbsp;<span>${ data.Id }</span>",
                    dataSource: {
                        minLength: 1,
                        type: "json",
                        schema: {
                            data: "d",
                        },
                        transport: {
                            read: {
                                url: "http://localhost/WCFTest/Service1.svc/QueryDatabase",
                                dataType: "json",
                                type: "POST"
                            },
                            parameterMap: function () {
                                var data = {
                                    columns: "cmp_name,cmp_id",
                                    table: "company",
                                    whereClause: "cmp_invcopies = 1"
                                };

                                return JSON.stringify(data);
                            },
                        }
                    },
                    filter: "startswith",
                    placeholder: "Select ...",
                    separator: ","
                });
            });
        </script>
        <style scoped="scoped">
            .k-autocomplete {
                width: 500px;
            }

            #AutoCompleteTest .k-autocomplete {
                width: 250px;
            }
        </style>
    </div>
Daniel
Telerik team
 answered on 27 Apr 2016
5 answers
378 views
Is there any way to check the status of the ctrl-key during a drop event?  I've tried monitoring the state of the ctrl key tracking the mouseup event in the treeview element but it doesn't fire when the drop is completed.  What I'm trying to accomplish is to only "copy" the node (rather than move it) if the user drags the node to another node when the ctrl key is held down.  
Kiril Nikolov
Telerik team
 answered on 27 Apr 2016
3 answers
154 views

Hi,

I have a grid with scrollable: { virtual: true }, pagesize: 25 setup with local data. I select a row and scroll away so paging happens, when I scroll back, and selection is lost. I saw other threads with suggested solution to do hacks around onChange and onDataBound event: http://jsbin.com/himuboxi/2/edit?html,output

My problem is, my grid is bound to local data, thus the DataBound event is fired when I scroll around. What other event could I depend on?

 

Best,

Ama

Kiril Nikolov
Telerik team
 answered on 27 Apr 2016
1 answer
128 views

Hi all,

I'm trying to save the current occurrence of the recurring event. But it cannot be saved, and I see the following error message in the console:

kendo.all.js:82119 Uncaught TypeError: Cannot read property 'isRecurrenceHead' of undefined

Could you please help me resolving it?

Kind Regards,

Georgi Krustev
Telerik team
 answered on 27 Apr 2016
1 answer
105 views

shapeMouseEnter and Leave events are sometimes called, but not always. To repeat this bug, just drag mouse over squares. Sometimes it is painted and sometime it is not.

dojo

T. Tsonev
Telerik team
 answered on 27 Apr 2016
1 answer
115 views

Can somebody please tell how to disable already applied dates.

For example, if i have selected range by entering start date and end date for a particular user then for that user next start date should show from previous end date

that is he shouldn't be able to select previous range.

Georgi Krustev
Telerik team
 answered on 27 Apr 2016
6 answers
742 views

For instance, kendo generates the following url for odata

http://gmovpwbwebdev01:8001/odata/PSellerPartnerMPNLocation?%24format=json&%24expand=PSeller%2C+Geography&%24top=20&%24orderby=PSEllerName&%24filter=((Geography%2FSubsidiaryDistrictId+eq+11182+or+Geography%2FSubsidiaryDistrictId+eq+11179)+and+(Geography%2FSubsidiaryId+eq+161+or+Geography%2FSubsidiaryId+eq+49)+and+Geography%2FAreaId+eq+5)&%24count=true

How do I retrieve the url that is build on the client.  I need to send the odata filter to the server for different processing and I don't want to build the string myself if kendo is already doing that.

T. Tsonev
Telerik team
 answered on 27 Apr 2016
1 answer
96 views

Hi,

We've run into a problem with using the autocomplete inside a grid.  The issue, as stated in the title, is that the popup is positioned in the upper left hand corner, rather than being positioned underneath the grid cell.

Here is a dojo which duplicates the problem: http://dojo.telerik.com/@villagemedia/ujize

Georgi Krustev
Telerik team
 answered on 27 Apr 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?