Telerik Forums
Kendo UI for jQuery Forum
4 answers
1.4K+ views
I’m trying to load a tree from a JSON string which is being returned from a Java action instead of having it statically inside the HTML.


The original code was like so:

<script>
    $("#treeview-left, #treeview-right").kendoTreeView({
        dragAndDrop: true,
            dataSource: [
                { text: "Item 1", expanded: true, items: [
                    { text: "Item 1.1" },
                    { text: "Item 1.2" },
                    { text: "Item 1.3" }
                ] },
                { text: "Item 2", items: [
                    { text: "Item 2.1" },
                    { text: "Item 2.2" },
                    { text: "Item 2.3" }
                ] },
                { text: "Item 3" }
                        ]
    }).data("kendoTreeView");
</script>



I modified it like so:

<script>
    $("#treeview-left, #treeview-right").kendoTreeView({
        dragAndDrop: true,
            dataSource: {
                transport: {
                    read: {
                        url: "/site/GetTreeData.action",
                        dataType: "json"
                    }
                }
            }
    }).data("kendoTreeView");
</script>



The GetTreeData.action returns the following JSON string:

[
{ text: "Item 1", expanded: true, items: [
    { text: "<a href='http://localhost:8080/site/GetEmployee.action'>clear here</a>", encoded: false },
    { text: "Item 1.2" },
    { text: "Item 1.3" }
] },
{ text: "Item 2", items: [
    { text: "Item 2.1", items: [
        { text: "Item 2.1.1" },
        { text: "Item 2.1.2" }
    ] },
    { text: "Item 2.2" },
    { text: "Item 2.3" }
] },
{ text: "Item 3" }
]

If I paste the previous JSON string inside the page and reload it, the tree displays just fine.

So, what am I doing wrong?

Hari
Top achievements
Rank 1
 answered on 10 Dec 2012
3 answers
420 views
Hello,
I've been reading the existing documentation about the Treeview as well as the Hierarchical Data Source and the Data Source but I kinda lost it about the possible remote data source types that I can use with the Treeview.
Apart from json,xml is also supported right?Is it possible to bind it and view the xml file with the Treeview?
I've been trying something like:

<title>Tree View</title>
     
<link href="shared/styles/examples-offline.css" rel="stylesheet">
<link href="styles/kendo.common.min.css" rel="stylesheet">
<link href="styles/kendo.blueopal.min.css" rel="stylesheet">
 
<script src="js/jquery.min.js"></script>
<script src="js/kendo.web.min.js"></script>
<script src="shared/js/console.js"></script>
 
</head>
<body>
        <div id="example" class="k-content">
        <div id="treeview" class="demo-section"></div>
 
            <script>
                var ds = new kendo.data.DataSource({
                        transport: {
                            read: {
                                url:"http://localhost:8080/OnTheSpotRestfullAPI/testTree.xml"
                            }
                        },
                        schema: {
                            type: "xml",
                            data: "/tree/vehicles",
                            model: {
                                fields: {
                                    car: "car/text()",
                                    bike: "bike/text()"
                                }
                            }
                        }
                    });
 
                $("#treeview").kendoTreeView({
                    dataSource: ds
                });
            </script>
 
            <style scoped>
                #example {
                    text-align: center;
                }
 
                .demo-section {
                    display: inline-block;
                    vertical-align: top;
                    width: 320px;
                    height: 300px;
                    text-align: left;
                    margin: 0 2em;
                }
            </style>
        </div>
 
 
</body>
</html>

with the testTree.xml being:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<tree>
    <vehicles>
        <car>FM-1100</car>
        <car>FM-4200</car>
        <bike>FM-3100</bike>
    </vehicles>
    <personnel>
        <client>GH-3000</client>
        <vip>GH-3100</vip>
    </personnel>
</tree>

but I can't seem to be able to view the tree at all..kinda lost here,can someone please point me to the right direction?

Thanks in advance
Hari
Top achievements
Rank 1
 answered on 10 Dec 2012
5 answers
196 views
To reproduce:
  1. Take the sample at http://demos.kendoui.com/mobile/actionsheet/index.html
  2. Modify to call the same event handler
<ul data-role="actionsheet" id="inboxActions" data-open="onOpen" data-popup='{"direction": "left"}'>
    <li class="km-actionsheet-title">Monday Meeting:</li>
    <li><a href="#" data-action="reply">Reply</a></li>
    <li><a href="#" data-action="replyAll">Reply All</a></li>
    <li><a href="#" data-action="archive">Archive</a></li>
</ul>

becomes

<ul data-role="actionsheet" id="inboxActions" data-open="onOpen" data-popup='{"direction": "left"}'>
    <li class="km-actionsheet-title">Monday Meeting:</li>
    <li><a href="#" data-action="singleEventHandler">Reply</a></li>
    <li><a href="#" data-action="singleEventHandler">Reply All</a></li>
    <li><a href="#" data-action="singleEventHandler">Archive</a></li>
</ul>

Then try implementing singleEventHandler as below:

function singleEventHandler(e) {
    if (<some test involving e>) {
        $("#actionResult").html("Replying to message #" + e.context);
    } else if (<some other test involving e>) {
        $("#actionResult").html("Replying to all in message #" + e.context);
    } else if (<some other test involving e>) {
        $("#actionResult").html("Archiving message #" + e.context);
    }
     doMoreStuff();
}

The problem is e only has two properties: target and context

target is not the button which has triggered the event but the button which has opened the action sheet, so there is no way to know which button in the action sheet has been triggered in the event handler.

If not a bug, this is in my opinion a design issue which prevents properly factoring code as the only workaround is to multiply event handlers when it is not always necessary.
Iliana Dyankova
Telerik team
 answered on 10 Dec 2012
1 answer
97 views
Here is a snippet:
columns.Bound(p => p.URL).Title("Url").Visible(false);
columns.Template(p => p.TRACKINGNUMBER).ClientTemplate(
    "<a href='#= URL #'>#= TRACKINGNUMBER #</a>"
    ).Title("Tracking Number");
The above above client template ignores the URL value and simply displays the tracking number has a regular text field.




Atanas Korchev
Telerik team
 answered on 10 Dec 2012
1 answer
324 views
Inside an MVVM bound template, how do I get access to the data item itself?

This doesn't give it to me (clearly eh) :)

<li data-bind="invisible: #= console.log(this) #">
    <span>test</span>
</li>
Petur Subev
Telerik team
 answered on 10 Dec 2012
2 answers
190 views
Hi, I am new here and i have question, I need a help?

I have jQuery Dialog form with tabs.
Inside this tab i want to have Kendo UI Editor but i have this problem when do this, Inside the tab, a kendo editor creates itself 2 times.

<div id="dialog">
<div id="tabs-7" style="height:540px; width:680px;">
                        @(Html.Kendo().Editor()
                          .Name("Editor")
                          .HtmlAttributes(new { style = "width: 500px;height:440px" })
                          .Value(@<text>
                                <p>
                                       Some text
                                </p>
                                 </text>))
                    </div> 
</div>
$("#dialog").dialog( ........);

Thanks,
Milan
                                 
Milan
Top achievements
Rank 1
 answered on 10 Dec 2012
1 answer
199 views
The calendar has a selected dates collection.  Is there an MVC example of binding to this collection.  I wan to be able to display selected dates allow uses to change the selected dates then save these changes back to the database,
Georgi Krustev
Telerik team
 answered on 10 Dec 2012
5 answers
2.7K+ views
So frustrating.

I have a scenario not extremely complicated in which i require items in my drop-down actually be databound before selecting a default item.

So when does this databound event actually run? Inside my databound event handler i am checking the count of items in the dropdownlist and it is ZERO.

I have been trying to track down phantom errors which are a result of either this bug or a misunderstanding of the docs for 2 weeks. Can someone from telerik expand on this? from the telerik api:

dataBound

Fires when the drop-down list has received data from the data source.

Example

$("#dropdownlist").kendoDropDownList({
    dataBound: function(e) {
        // handle event
    }
});

To set after initialization

// get a reference to the dropdown list
var dropdownlist = $("#dropdownlist").data("kendoDropDownList");
// bind to the close event
dropdownlist.bind("dataBound", function(e) {
    // handle event
});


Have i misread "receive" data to mean received and bound the data? When really it's not databound? If so it would be extremely useful to have an actual databound event for the dropdownlist that was fired AFTER the items have been created.
Georgi Krustev
Telerik team
 answered on 10 Dec 2012
2 answers
83 views
Can anyone out there help me with getting a panel bar working correctly?  No matter what tutorial I try, or sample code I use - I cannot get it to work???

Thanx in Advance,
Chris
Chris
Top achievements
Rank 1
 answered on 10 Dec 2012
1 answer
128 views
I meant ClientTemplate. It won't let me edit the title of this post.

        columns.Bound(t => t.IsOpen)
        .Title("Status")
        .ClientTemplate(
            "# if (#=IsOpen# == 'True') { #" +
            "something" +
            "# } else { #" +
            "something else" +
            "# } #"
        );

Uncaught Error: Invalid template:'<tr data-uid="#=uid#"><td ># if (#=IsOpen# == 'True') { #something# } else { #something else# } #</td></tr>' Generated code:'var o,e=kendo.htmlEncode;with(data){o='<tr data-uid="'+(uid)+'"><td >'; if (;o+='=IsOpen'; == 'True') { ;o+='something'; } else { ;o+='something else'; } ;o+='</td></tr>';}return o;'

        
Atanas Korchev
Telerik team
 answered on 10 Dec 2012
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
SegmentedControl
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?