Telerik Forums
Kendo UI for jQuery Forum
6 answers
533 views
With this data:
var fails = 
[
  { id: 0, name: 'zero', complex: { name: 'complex 0' } },
  { id: 1, name: 'one', complex: null }
];

And these columns:
var columns = 

  { title: "id", field: "id" },
  { title: "name", field: "name" },
  { title: "complex", field: "complex.name" }
];

This throws an exception and fails to render any data:
$("#fails").kendoGrid({
  dataSource: fails,
  columns: columns
});

JSBin demo here: http://jsbin.com/omuviw/3/edit
Cody
Top achievements
Rank 1
 answered on 24 Jul 2013
9 answers
347 views
I am trying to use pinned so that a simple window will have a fixed position. 

1) setting pinned to true seems to do nothing.
2) calling pin() on a window results in a javascript error. Uncaught TypeError: Object [object Object] has no method 'pin'

I am a newbie with Kendo.  Using 2013.1.514 downloaded today from Kendo.

$(document).ready(function( event ) { 

    var window = $("#add-comment");

    window.kendoWindow({
        width: "300px",
        height: "315px",
position: {
       top: 100,
       left: 100
   },        
title: "Add Comment",
modal: true,
visible: false,
pinned: true,
        actions: ["Maximize", "Close"],
    });

    $(".comment-button").on("click", function (e) {
   var kendoWindow = $("#add-comment").data("kendoWindow");
kendoWindow.center(); // no error, works
kendoWindow.open(); // no error, opens window
kendoWindow.pin(); // js exception
    });
Joe
Top achievements
Rank 1
 answered on 24 Jul 2013
4 answers
1.3K+ views
Hello,  I have selectable() enabled in my code but it still won't work, I want to be able to select a row and have additional data from the entry to be displayed below the table. I've tried a few different ways and can't seem to get it to work. My code is: 

@(Html.Kendo()
        .Grid<SiteLogEntry>()
        .Name("Logs")
        .EnableCustomBinding(true)
        .Columns(c =>
            {
                c.Bound(p => p.LogId).Title("Log ID");
                c.Bound(p => p.ServerName).Title("Server Name");
                c.Bound(p => p.DateEntered).Title("Date Entered").Format("{0:MM/dd/yyyy h:m:ss tt}").Width("150px");
                c.Bound(p => p.DateLogged).Title("Date Logged").Format("{0:MM/dd/yyyy h:m:ss tt}").Width("150px");
                c.Bound(p => p.SourcePage).Title("Source Page");
                c.Bound(p => p.SourceObject).Title("Source Object");
                c.Bound(p => p.Description).Title("Description");
                c.Bound(p => p.ErrorMessage).Title("Error Message");
                c.Bound(p => p.AdditionalData).Title("Additional Data");
                c.Bound(p => p.Severity).Title("Severity");
            })
            .Resizable(resize => resize.Columns(true))
            .Sortable(s => s.Enabled(true))
            .Selectable(s => s.Enabled(true).Mode(GridSelectionMode.Single).Type(GridSelectionType.Row))
            .Scrollable()
            
            .Filterable(f => f.Enabled(true)
        .Extra(false)
        .Operators(operators => operators
            .ForString(str => str.Clear()
                .StartsWith("Starts with")
                .IsEqualTo("Is equal to")
                .IsNotEqualTo("Is not equal to")
            ))
        )   
            .HtmlAttributes(new { style = "height: 400px; width: 1500px; align: right;" })
            .Pageable(p => p.Enabled(true).Refresh(true))
            .DataSource(ds => ds
                .Ajax()
                .PageSize(10)
                .Read(read => read
                    .Action("GetLog", "SiteLog").Data("times"))
                    .Sort(z => z.Add(t => t.DateEntered).Descending())
                    )
            )


Nothing really changes whenever I enable/disable selectable. My end goal is to have the description, message, and data only show a small portion of their value within the table, then on selection populate a div below the table with their full entries. I've checked a number of the kendo demos but none have helped solve this issue.  Thanks for any help with this issue. 
Tracey
Top achievements
Rank 1
 answered on 24 Jul 2013
3 answers
294 views
Is it possible to bind data from a viewmodel to data-columns? I tried the following to no avail.

<div data-role="grid"
                    data-sortable="true" data-editable="true"
                    data-columns="source: myColumns"
                    data-bind="source: entities"
                    data-row-template="rowTemplate"></div>



Cody
Top achievements
Rank 1
 answered on 24 Jul 2013
1 answer
66 views
Hi,

I thought Unobtrusive JavaScript event is more faster and a best practice over obtrusive . But in Kendo mobile, there is 'data-click' to attach event to element which seems to be  obtrusive event for me. Which way is the Best practice in Kendo mobile application and why?

Thanks,
Amrutha.

Petyo
Telerik team
 answered on 24 Jul 2013
6 answers
988 views
Hi,

I just spent the last couple of hours trying to get the ComboBox to work, but no luck so far. Here's the code breakdown:
Datasource:
var event_datasource = new kendo.data.DataSource({
    transport: {
        read: {
            url: "/event/datawidget",
            dataType: "json",
            type: "POST"
        },
        parameterMap: function(data) {
            return kendo.stringify(data);
        }
    },
    schema: {
        data: "data",
        total: "total",
        model: {
            id: "event_id",
            fields: {
                event_id: { type: "number" },
                description: { type: "string" }
            }
        }
    },
    sort: { field: "description", dir: "desc" }
    pageSize: 10,
    serverFiltering: true,
    serverPaging: true
});
ComboBox:
var event_widget = $("#event_id").kendoComboBox({
    dataTextField: "description",
    dataValueField: "event_id",
    filter: "contains",
    minLength: 2,
    dataSource: event_datasource,
    placeholder: "Select an event",
    value: '99',
    text: 'Some event',
    change : function (e) {
        if (this.value() && this.selectedIndex == -1)
            this.value(null); // clears the selection when an invalid selection was made
    },
      autoBind: false
}).data('kendoComboBox');
Problem:
The initial dataset that the datasource returns does not contain value 99 (Some Event).
When I set autoBind to false then the value and text are correctly shown upon initialization.

BUT, when I simply click the little arrow on the dropdown, the data is bound, the text "Some Event" disappears, and the shown text is set to 99 (aka the value).
Even when I don't actually select another item from the combobox, it keeps showing 99.

I've tried using the datasource filter to filter the selected event id, but I cannot unset this filter afterwards (or don't know how to do this properly; everything I tried just made things worse).

Can anyone tell me what I'm doing wrong here? Also, if someone has a clean and working solution to this, I recommend adding it to the documentation because more people seem to be struggling with this (based on similar threads in this forum).

Regards,
Rinck
Rinck
Top achievements
Rank 1
 answered on 24 Jul 2013
1 answer
61 views
I have a Window that opens the first time and closes the first time fine. Works great.

Html.Kendo().Window()
    .Name(windowId)
    .Width(680)
    .Height(430)
    .Title(Model.ChartTitle)
    .Visible(false)
    .Modal(true)
    .Draggable(true)
    .Animation(animation => { animation.Open(open => { open.Fade(FadeDirection.In); }); })

However, the second time the window opens when clicked by a user, the entire window and contents is 50% sized. Images, text everything.

I experimented and found if I remove the .Animation line the Window works as expected each time.

Bug?

Vladimir Iliev
Telerik team
 answered on 24 Jul 2013
1 answer
108 views
Hi,

  I am using Kendo UI-  Grid  in my screen, but unfortunately I had some issue with it.

In my Kendo().Grid , I am using the RowTemplate. It have a property  called ClientRowTemplate, on that  , we are using below line of code to show an image.

“ "<img src='" + Url.Content("~/Content/Images/") +"#:data.ImageFileName#' alt='#: “data.ImageFileName #' style =width:50px; />" .

 But  I want to give another path like Url.Content("D:\Images\1")   , but it is not taking the path. Images were not shown  from these path.Why is it so?

Vladimir Iliev
Telerik team
 answered on 24 Jul 2013
1 answer
206 views
I have a grid with incell editing enabled and keyboard navigation.

Based on business rules we are disabling some cells based on the values on some other columns.

The problem is that when navigation through each cell, when you move into a cell disable with closeCell() method, the grid lost focus, and page
scroll up and focus into some of the headers elements.
01.function onCommitmentEdit(e) {
02.       console.log("onCommitmentEdit");
03.       //debugger;
04.       var cell = e.container;
05.        
06.       var $bigStringEditor = cell.find(".big-string-editor");
07. 
08.       if ($bigStringEditor.length == 1) {
09.           $bigStringEditor.keydown(function (ev) {
10.               stop(ev);
11.           });
12.           
13. 
14.           $bigStringEditor.mousedown(function (ev) {
15.               if (ev.button == 0) {
16.                   ev.stopPropagation();
17.               }
18.           });
19. 
20.       }
21.       
22.       //debugger;
23.       switch (cell[0].cellIndex) {
24.           case PROJECT_COLUMN:
25.               //only enabled if Type = "Separately Budgeted"
26.               if (e.model.CommitmentTypeId != 3) {
27.                   this.closeCell();
28.               }
29.               break;
30.           case OFF_TRACK_IMPLICATION_COLUMN:
31.               //only enabled if Execution is "Behind" or "Failing", or Budget= "Over"
32.               if (e.model.CommitmentStatusTypeId != 3 && e.model.CommitmentStatusTypeId != 4 && e.model.BudgetStatusTypeId != 1) {
33.                   this.closeCell();
34.               }
35.               break;
36.           case DEPARTMENTS_INVOLVED_COLUMN:
37.               //only enabled if Cross Department = True
38.               if (!e.model.CrossDepartment) {
39.                   this.closeCell();
40.               }
41.               break;
42.           case CANCEL_OK_COLUMN:
43.               //only enabled if Execution is "Cancelled"
44.               if (e.model.CommitmentStatusTypeId != 6) {
45.                   this.closeCell();
46.               }
47.               break;
48. 
49.       }
50.       e.model.SubGroupId = getSubGroupIdVal();
51.       e.model.DashboardId = getDashBoardIdVal();
52. 
53.   }
Thanks in advance,

Gon
Dimiter Madjarov
Telerik team
 answered on 24 Jul 2013
1 answer
1.0K+ views
Hi Everyone,

I'm the lead developer on an ASP.NET WebForms project (Sadly, this choice was mine just prior to my arrival and the lead at the time left shortly thereafter leaving me stuck with a less than preferred ASP.NET option).
Anyways, I recently recommended purchase of 2 licenses for the DevCraft Complete package to my employeer. One license is mine while the other goes to another developer who strongly prefers the ASP.NET AJAX controls for WebForms. We're both preparing some proof of concepts to present to the project manager. I need to show that using Kendo UI with MVVM  will offer better performance both client and server side, less latency, less bandwidth and the easiest to learn for our other developers.

I need to create a simple read-only page which uses two models . For each Category I need to display the Name. Just under this header, For each Ticket associated with this category, I need to display the Name and Date of submission for the 20 most recent tickets (I intend to use serverPaging on the DataSource). I then want to attach a click handler to each Ticket Name which will make a call and pass the ID of this Ticket causing the system to return the content for this ticket which will be displayed in a pop-up window.

As my business objects typically contain more properties than I need for a given page - we're creating the JSON models separately. (Fig 1a & 1b respectively)

What I first tried was creating a web service call which returns  an array of Category objects which each contain the Tickets associated with that Category. The JSON for this can be seen in Fig 2.

I've found mixed examples switching between a standard DataSource and a HierarchicalDataSource for this scenario. My current javascript can be seen in Fig 3.

Finally the MVVM portion -- the HTML can be seen in Fig 4. I don't feel this is too complex but it seems some I'm missing a few things. When I run this, only the Categories JSON is returned and no binding occurs. No errors are thrown either.

These are the entity models server side:
Fig. 1a
01.namespace ProofOfConcept.BO
02.{
03.    public class Ticket
04.    {
05.        public int ID { get;set; }
06.        public int CategoryID { get;set; }
07.        public string Name { get;set; }
08.        public string Content { get;set; }
09.        public DateTime DateSubmitted { get;set; }
10.    }
11. 
12.    public class Category
13.    {
14.        public int ID { get;set; }
15.        public string Name { get;set; }
16.        public List<Ticket> Tickets { get;set; }
17.    }
18.}



These are the models which I serialize into JSON. I read that I should modify them as shown below -- see comments.

Fig 1b
01.namespace ProofOfConcept.JSONModels
02.{
03. 
04.    public class Ticket
05.    {
06.        // Key values are encrypted into a string before being sent to the client
07.        public string ID { get;set; }
08.        public string CategoryID { get;set; }
09.        public string Name { get;set; }
10.        public string Content { get;set; }
11. 
12.        // I would prefer a DateTime value but I don't know if
13.        // converting the value and displaying it properly is supported
14.        public string DateSubmitted { get; set; }
15.    }
16. 
17.    public class Category
18.    {
19.        // Key values are encrypted into a string before being sent to the client
20.        public string ID { get;set; }
21.        public string Name { get;set; }
22.     
23.        // I read that the property for the nested object(s) should
24.        // be removed from the JSON model -- is this correct? 
25.        // public List<Ticket> Tickets { get;set; }
26.    }
27. 
28.}

Is it possible that I can just send all the data across in this format from just one handler and have the MVVM function with the nested templates? or am I correct that I must use a HierarchicalDataSource? If so, do I have it correctly implemented as shown below?

Fig 2
01.[
02.    {
03.        "ID": "1",
04.        "Name": "CategoryName1",
05.        "Tickets": [
06.            {
07.                "ID": "10",
08.                "Name": "name value",
09.                "CategoryID": "1",
10.                "Content": "content here",
11.                "DateSubmitted": "serialized DateTime here"
12.            },
13.            {
14.                "ID": "11",
15.                "Name": "name value",
16.                "CategoryID": "1",
17.                "Content": "content here",
18.                "DateSubmitted": "serialized DateTime here"
19.            },
20.            {
21.                "ID": "12",
22.                "Name": "name value",
23.                "CategoryID": "1",
24.                "Content": "content here",
25.                "DateSubmitted": "serialized DateTime here"
26.            }
27.        ]
28.    }, // ... Removed for readability
29.]

This is the javascript I've got so far -- I've bounced between a simple DataSource and a HierarchicalDataSource but I've been unable to find enough examples on this site (with the documentation and forums) that nail down a concrete implementation.

Fig 3
01.$(document).ready(function ()
02.{
03.    // Objects are defined individually as I want to create
04.    // a single file with all object definitions so that other
05.    // developers can recycle them.
06.    var Ticket = kendo.data.Model.define(
07.    {
08.        id: "ID",
09.        fields:
10.        {
11.            ID: { type: "string" },
12.            CategoryID: { type: "string" },
13.            Name: { type: "string" },
14.            Content: { type: "string" },
15. 
16.            // Is there a Date (or DateTime) type?
17.            DateSubmitted: { type: "string" },
18.            hasChildren: false
19.        }
20.    });
21. 
22.    var Category = kendo.data.Model.define(
23.    {
24.        id: "ID",
25.        fields:
26.        {
27.            ID: { type: "string" },
28.            Name: { type: "string" },
29.            hasChildren: true,
30.            children: Tickets
31.        }
32.    });
33. 
34.    // The ID of the Category is passed to the handler 
35.    // in this format: Tickets.ashx?CID=2
36.    // If possible, I'd also like to pass the ID of the ticket,
37.    // Tickets.ashx?ID=44 which would return the full Ticket (ie: with Content)
38.    var Tickets =
39.    {
40.        transport:
41.        {
42.            read:
43.            {
44.                 url: "Tickets.ashx",
45.                 type: "GET",
46.                 dataType: "json",
47.                 contentType: "application/json; charset=utf-8"
48.            }
49.         },
50.         schema:
51.         {
52.            data: "d",
53.            model: Ticket
54.         }
55.    };
56. 
57. 
58.    var Categories = new kendo.data.HierarchicalDataSource(
59.    {
60.        transport:
61.        {
62.            read:
63.            {
64.                url: "Categories.ashx",
65.                type: "GET",
66.                dataType: "json",
67.                contentType: "application/json; charset=utf-8"
68.            }
69.        },
70.        schema:
71.        {
72.            data: "d",
73.            model: Category
74.        }
75.    });
76. 
77. 
78.    var viewModel = kendo.observableHierarchy(
79.    {
80.            Categories: Categories
81.    });
82. 
83.    kendo.bind($("#divCategory"), viewModel);
84. 
85.});
Fig 4
01.<section>
02. 
03.   <div id="divCategory" data-template="category-template" data-bind="source: Categories" >
04.       <ul data-template="ticket-template" data-bind="source: Tickets" id="divTicket">
05.       </ul>
06.   </div>
07. 
08.   <script id="category-template" type="text/x-kendo-template">
09.       <h2 data-bind="text: Name"></h2>
10.   </script>
11. 
12. <script id="ticket-template" type="text/x-kendo-template">
13.       <li>
14.           <a data-bind="attr: { href: ID }">
15.               <span data-bind="text: Name" ></span>
16.           </a>
17.           <span data-bind="text: DateSubmitted" ></span>
18.       </li>
19. </script>
20. 
21.</section>

I look forward to your reply.

Thank you,
Daniel
Telerik team
 answered on 24 Jul 2013
Narrow your results
Selected tags
Tags
Grid
General Discussions
Charts
Data Source
Scheduler
DropDownList
TreeView
MVVM
Editor
Window
Date/Time Pickers
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)
SPA
Filter
Drawing API
Drawer (Mobile)
Globalization
Gauges
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
OrgChart
TextBox
Effects
Accessibility
ScrollView
PivotGridV2
BulletChart
Licensing
QRCode
ResponsivePanel
Switch
Wizard
CheckBoxGroup
TextArea
Barcode
Collapsible
Localization
MultiViewCalendar
Touch
Breadcrumb
RadioButton
Stepper
Card
ExpansionPanel
Rating
RadioGroup
Badge
Captcha
Heatmap
AppBar
Loader
Security
Popover
DockManager
FloatingActionButton
TaskBoard
CircularGauge
ColorGradient
ColorPalette
DropDownButton
TimeDurationPicker
ToggleButton
BottomNavigation
Ripple
SkeletonContainer
Avatar
Circular ProgressBar
FlatColorPicker
SplitButton
Signature
Chip
ChipList
VS Code Extension
AIPrompt
PropertyGrid
Sankey
Chart Wizard
OTP Input
SpeechToTextButton
InlineAIPrompt
+? 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?