Telerik Forums
Kendo UI for jQuery Forum
2 answers
107 views
So this code is identical to code I have on my other views.  The only thing I can't figure out, is why inlcuding data-views PREVENTS the window from opening up on in this view.  The data-views path is correct.  I can even copy paste code that works perfects with other views I have that also uses data-views, include the view I want to open on and it still won't work.  

Why would data-views prevent the drawer from opening on a page that has been added to data-views? And more so, why does it not work here, but work everywhere else I use it.

<div id="drawerAccounts"
     data-role="drawer"
     data-views='[
    "/View/Account/AccountDefaultView.htm"                     //This is the correct file path and this is the view where the drawer is located.
    ]'
     data-show="accountListDrawerController.showEvent"
     data-model="accountListDrawerController.dataModel">
    <ul data-role="listview" data-type="group" data-click="clk">
        <li>
            [Person Name]
            <ul>
                <li><a href="#" data-link="/view/editPerson/editPersonDefaultView.htm?id=#id#" data-bind="idLink: id" data-transition="none">Back to Person</a></li>
            </ul>
        </li>
        <li>
            Other
            <ul>
                <li><a onclick="crmMobile.showThemeModal(); HideDrawer('drawerAccounts');">Change UI Theme</a></li>
                <li><a href="#" data-link="/view/Misc/MiscAboutVA.htm" data-transition="none">About Virtual Advisor</a></li>
                <li><a href="/view/Misc/MiscLoggingOut.htm" onclick="logOut();" data-transition="none">Logout</a></li>
            </ul>
        </li>
    </ul>
</div>


Here is a sample of my code from a view that works correctly.
Snippet<div id="drawerEditPerson"
     data-role="drawer"
     data-views='[
    "/view/editPerson/editPersonDefaultView.htm",
    "/view/editPerson/widget/editPersonStatusView.htm",
    "/view/editPerson/widget/editPersonDetailsView.htm",
    "/view/editPerson/widget/editPersonNameView.htm",
    "/view/editPerson/widget/editPersonDisciplinesView.htm",
    "/view/editPerson/widget/viewPersonDisciplinesView.htm",
    "/view/editPerson/widget/viewPersonElectronicContactView.htm",
    "/view/editPerson/widget/viewPersonContactNumbersView.htm",
    "/view/editPerson/widget/viewPersonAddressesView.htm",
    "/view/editPerson/widget/EditPersonRemarksView.htm",
    "/view/editPerson/widget/ViewPersonCompaniesView.htm",
    "/view/editPerson/widget/ViewPersonGroupsView.htm",
    "/view/editPerson/widget/viewPersonNotesView.htm",
    "/view/editPerson/widget/viewPersonRelationshipsView.htm",
    "/view/editPerson/widget/viewPersonCampaignsView.htm",
    "/view/editPerson/widget/viewPersonDocumentsView.htm",
    "/view/editPerson/widget/viewPersonActivitiesView.htm"
    ]'
     data-show="peopleEditDrawerController.showEvent"
     data-model="peopleEditDrawerController.dataModel">
    <ul data-role="listview" data-type="group" data-click="clk">
        <li>
            Contact Info
            <ul>
                <li><a href="#" data-link="/view/editPerson/editPersonDefaultView.htm?id=#id#" data-bind="idLink: id" data-transition="none">Preview</a></li>
                <li><a href="#" data-link="/view/editPerson/widget/editPersonNameView.htm?id=#id#" data-bind="idLink: id" data-transition="none">Name</a></li>
                <li><a href="#" data-link="/view/editPerson/widget/editPersonStatusView.htm?id=#id#" data-bind="idLink: id" data-transition="none">Status</a></li>
                <li><a href="#" data-link="/view/editPerson/widget/editPersonDetailsView.htm?id=#id#" data-bind="idLink: id" data-transition="none">Details</a></li>
                <li><a href="#" data-link="/view/editPerson/widget/editPersonDisciplinesView.htm?id=#id#" data-bind="idLink: id" data-transition="none">Disciplines</a></li>
                <li><a href="#" data-link="/view/editPerson/widget/viewPersonElectronicContactView.htm?id=#id#" data-bind="idLink: id" data-transition="none">Electronic Contact</a></li>
                <li><a href="#" data-link="/view/editPerson/widget/viewPersonContactNumbersView.htm?id=#id#" data-bind="idLink: id" data-transition="none">Contact Numbers</a></li>
                <li><a href="#" data-link="/view/editPerson/widget/viewPersonAddressesView.htm?id=#id#" data-bind="idLink: id" data-transition="none">Address</a></li>
                <li><a href="#" data-link="/view/editPerson/widget/EditPersonRemarksView.htm?id=#id#" data-bind="idLink: id" data-transition="none">Remarks</a></li>
                <li><a href="#" data-link="/view/editPerson/widget/ViewPersonGroupsView.htm?id=#id#" data-bind="idLink: id" data-transition="none">Groups</a></li>
                <li><a href="#" data-link="/view/editPerson/widget/viewPersonNotesView.htm?id=#id#&includeGeneral=true&includeActivity=false&includeDocument=false&includeGroup=false&includeAccount=false" data-bind="idLink: id" data-transition="none">Notes</a></li>
                <li><a href="#" data-link="/view/Account/AccountDefaultView.htm?id=#id#" data-bind="idLink: id" data-transition="none">Accounts</a></li>
            </ul>
        </li>
        <li>
            Other
            <ul>
                <li><a onclick="crmMobile.showThemeModal(); HideDrawer('drawerEditPerson');">Change UI Theme</a></li>
                <li><a href="#" data-link="/view/Misc/MiscAboutVA.htm?id=#id#" data-bind="idLink: id" data-transition="none">About Virtual Advisor</a></li>
                <li><a href="/view/Misc/MiscLoggingOut.htm" onclick="logOut();" data-transition="none">Logout</a></li>
            </ul>
        </li>
    </ul>
</div>
Petyo
Telerik team
 answered on 22 Jan 2014
1 answer
244 views
I am getting an 'object reference not set to an instance of an object' error on the mobile drawer when trying to add it to the _Layout.cshtml of my application.  Are you allowed to use the mobile drawer in the _Layout without setting up any mobile views or mobile layouts?  If so, could you provide an example or show me where I am going wrong.  Below are code snippets from my _Layout.cshtml file:

Below are my CSS and JS files in the head section of _Layout.cshtml:
<link href="@Url.Content("~/Content/kendo/2013.3.1119/kendo.bootstrap.min.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/kendo/2013.3.1119/kendo.common-bootstrap.min.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/kendo/2013.3.1119/kendo.mobile.all.min.css")" rel="stylesheet" type="text/css" />
 
<link href="@Url.Content("~/Content/bootstrap/bootstrap.min.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/bootstrap/bootstrap-theme.min.css")" rel="stylesheet" type="text/css" />
 
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
 
<script src="@Url.Content("~/Scripts/kendo/2013.3.1119/jquery.min.js")"></script>
<script src="@Url.Content("~/Scripts/kendo/2013.3.1119/kendo.all.min.js")"></script>

Below is where I am creating my mobile drawer inside of the body tag in my _Layout.cshtml file:
@(Html.Kendo().MobileDrawer()
    .Name("my-drawer")
    .HtmlAttributes(new { style = "width: 270px" })
    .Content(obj =>
        Html.Kendo().MobileListView().Type("group")
            .Items(root =>
            {
                root.Add().Text("Navigation");
                root.Add().Text("Account");
            })
    )
)
 
<div class="container">
    <div class="row">
        <!-- main area -->
        <div class="col-xs-12">
            @RenderBody()
        </div>
    </div>
</div>

And below is my JavaScript that I have at the bottom of my body tag in _Layout.cshtml:
script src="@Url.Content("~/Scripts/bootstrap/bootstrap.min.js")" type="text/javascript"></script>
 
<script type="text/javascript">
    var app = new kendo.mobile.Application(document.body,
        {
            skin: "flat",
            initial: @Url.Action("Index", "Home")
        });
</script>
Kiril Nikolov
Telerik team
 answered on 22 Jan 2014
1 answer
186 views
We're dynamically updating values in the dataSource of a grid using it's dataSource.data() method and whilst the Total aggregate seems to work, the group aggregates don't update. 

Is there a way to force these calculation to be executed after the data() method is called? 

Thanks,
Jacques
Petur Subev
Telerik team
 answered on 22 Jan 2014
1 answer
80 views
I am trying to get a listview filled with messages that reside in an array in the ViewModel. When i click on a category  the function updateMessages is called. (shown below)

01.function updateMessages(id, title) {
02.    var data = {
03.        'language': "en",
04.        'api_version': '2'
05.    };
06.    var categoryId = id.split('-').pop();
07.    categoryId = typeof categoryId !== 'undefined' ? categoryId : "";
08. 
09.    var url = SERVER_NAME;
10.    if (categoryId === "") {
11.        url += '/secret/all';
12.    }
13.    else {
14.        url += '/secret/category/' + categoryId;
15.    }
16.    url += '?callback=?';
17.    $.getJSON(url, data, function(json) {
18.        var messages = '';
19.        $.each(json.messages, function() {
20.            messagesViewModel.addMessage(this.id, this.message, this.machine_timestamp, this.human_timestamp, this.number_comments)
21.        });
22.        messagesViewModel['title'] = title;
23.    });
24.    app.application.navigate('messages.html');
25.}


updateMessages fills in the messagesViewModel:

1.var messagesViewModel = kendo.observable({
2.    messages: [],
3.    title: '',
4.     
5.    addMessage: function(id, message, machineTimestamp, humanTimestamp, comments){
6.        this.messages.push({id:id, message:message, machineTimestamp: machineTimestamp, humanTimestamp: humanTimestamp, comments:comments});
7.    },   
8.})

Which then gets shown in the view like this:
01.<!DOCTYPE html>
02. 
03.<html>
04.    <head>
05.        <title></title>
06.    </head>
07.    <body>
08.        <div id="messageList" data-role="view" data-title="Secrets" data-model="messagesViewModel">
09.            <div id="messagesViewContent" data-role="content">
10.                <!-- list of secrets -->
11.                <ul id="messageList" data-role="listview" data-bind="source: messages" data-template="messagesTemplate" data-auto-bind="false">
12.                </ul>
13.            </div>
14. 
15.            <script type="text/x-kendo-template" id="messagesTemplate">
16.                <a id="#:id#" href="messageDetails.html?id=#:id#&message=#:message#">
17.                    <p>#:message#</p>
18.                </a>
19.            </script>
20.        </div>
21.    </body>
22.</html>

The problem is that everytime I click on a category the array just keeps on filling up. I want to empty the array before adding new messages. I tried to add a clearMessage function in the viewmodel that executed: this.messages.length = 0. This cleared the array but in the view model you can still see all the old messages. How can I remove those messages everytime this view is called upon.
Petyo
Telerik team
 answered on 22 Jan 2014
1 answer
240 views
Hi,

I'm trying out MVVM binding on HTML for the first time and have come across a scenario which i cant find any examples of.

What i'm trying to do is bind a lot of controls on my view to the viewmodel so (like silverlight) if a control changes value, i can check the viewmodel has changed and raise a haschanges or a similar event. - and i think this is possible using the MVVM model.

I currently had the drop down control bind to the controller like so:

@(Html.Kendo().ComboBox()
                .Name("BusinessUnitComboBox")
                .Filter("contains")
                .Placeholder("Select Business Unit...")
                .DataSource(src =>
                {
                    src.Read(read =>
                    {
                        read.Action("GetBusinessUnits", "Home", new { CompanyId = ViewBag.CompanyId });
                    });
                })
                .DataTextField("Name")
                .DataValueField("BusinessUnitId")
                .Suggest(true)
                .HtmlAttributes(new { style = "width: 250px" })
                .Events(e => e.Change("BusinessUnitChanged"))

How would i be able to call this method using the MVVM way?

Currently i have:

<select data-role="combobox" data-text-field="Name" data-value-field="BusinessUnitId" data-bind="source: buSource, value: BusinessUnitComboBox"></select>

as the html and after reading a guide, i have the following as my script:

var viewModel = kendo.observable({
            buSource: new kendo.data.DataSource({
                transport: {
                    read: {
                        url: crudServiceBaseUrl + "/Products",
                        dataType: "jsonp"
                    },
                    parameterMap: function (options, operation) {
                        if (operation !== "read" && options.models) {
                            return {
                                models: kendo.stringify(options.models)
                            };
                        }
                        return options;
                    }
                },
                batch: true,
            }),
            BusinessUnitComboBox: null,
            hasChanges: false,
            save: function () {
                this.productsSource.sync();
                this.set("hasChanges", false);
            }
        });

Would someone be able to guide me or point me in the right direction on  how to bind to the controller as i've done using the kendo control itself and also how to use the parameterMap?



Thanks in advance.
Petur Subev
Telerik team
 answered on 22 Jan 2014
2 answers
434 views
Hi,
 My requirement is  windowsexplorer-like-treeview  as explained in this  tutorial .Can you help me to do it in  Kendo ui Web .We are using Java and kendo ui web.
I need to show  hierarchy structure at left side  and upon clicking  the files inside the sub-folders  I Need to display the file content in the right side.
As I am new to kendo ui  Kindly suggest me   with a demo and it would be a great help.

Thanks in Advance.
Winds

monty
Top achievements
Rank 1
 answered on 22 Jan 2014
3 answers
53 views
There is a bug in Kendo Mobile where Kendo tries to be smart and work around the Mobile Safari bug where the footer obscures the bottom 20px in certain scenarios, which leads to a white strip appearing when run as a cordova application.

The Kendo workaround is defined in kendo.mobile.js as BROKEN_WEBVIEW_RESIZE ( line 16876 ). This line currently reads
        BROKEN_WEBVIEW_RESIZE = OS.appMode && OS.ios,
but it should probably be either 
        BROKEN_WEBVIEW_RESIZE = ! OS.appMode && OS.ios,
or OS.appMode has a bug that leads it to return the wrong value.

Either way, the bug leads to the 20px "correction" to take place, resulting in a 20px high white strip at the bottom of the app. 

This has been tested with cordova 3.3.1-0.1.2 and iOS 7.0.3 (simulator and device).

Thanks,
Max


Max
Top achievements
Rank 1
 answered on 21 Jan 2014
2 answers
107 views
I have a kendo view that is bound to a kendo.observable with accept and reject actions.  When reject is selected, I pop up a modalview that includes an input which requires comments as why they are rejecting.  The modal has two buttons, Reject and Cancel.  If the users hits accept, I want to send the input back to the original views viewModel.  I also expect all execution to stop when the modal is open, but it continues to run.

Here is a snippet of the viewModel and the modal view.
vm:
var viewModel = kendo.observable({
    accept: function () {
        // ajax call
    },
    reject: function () {
        utils.showReject(); // modalview
 
        // get response from showReject (i.e., if they hit Reject,
        // give me their comments from the input)
 
        // ajax call with comments from above
    }
});
utils.showReject();
var showReject = function () {
        $("#reject-view").show().data().kendoMobileModalView.open();
    }
html:
<div data-role="modalview" id="reject-view" style="display: none; width: 70%;">
        <div data-role="header">
            <div data-role="navbar">
                <span>Are you sure?</span><br />
                <textarea rows="3" placeholder="Enter Reject Reason" style="width: 95%; padding: 5px;"></textarea><br />
                <a data-click="app.closeModal" data-modalid="#reject-view" data-role="button">Reject</a>
                <a data-click="app.closeModal" data-modalid="#reject-view" data-role="button">Cancel</a>
            </div>
        </div>
    </div>

Thomas
Top achievements
Rank 1
 answered on 21 Jan 2014
1 answer
96 views
I'm so much frustrated using kendo mobile... there's so many issues. I'm not sure whether I'm coding bad,,,,

Here's my another problem....

when listview (binds to remote datasource) reaches end, and user can click the detail button from the list to see more information.
It works fine when listview didn't reach end, but when it reaches end (using 'load more' button) and user clicks the detail button to see more information, I get 


Uncaught TypeError: undefined has no properties
(anonymous function)
b.isFunction.i jquery.min.js:3
C.render kendo.mobile.min.js:12
b.isFunction.i jquery.min.js:3
y.extend._renderItems kendo.mobile.min.js:18
y.extend.insertAt kendo.mobile.min.js:18
y.extend.append kendo.mobile.min.js:18
g.Class.extend.init kendo.mobile.min.js:18
$.item kendo.mobile.min.js:18
g.Observable.extend.refresh kendo.mobile.min.js:18
(anonymous function) kendo.mobile.min.js:18
i.extend.trigger kendo.mobile.min.js:12
lt.Observable.extend._change kendo.mobile.min.js:15
(anonymous function) kendo.mobile.min.js:15
i.extend.trigger kendo.mobile.min.js:12
ut.extend._process kendo.mobile.min.js:14
ut.extend.success kendo.mobile.min.js:14
b.isFunction.i jquery.min.js:3
n.success kendo.mobile.min.js:14
c jquery.min.js:3
p.fireWith jquery.min.js:3
k jquery.min.js:5
r jquery.min.js:5

This error is generated when calling DataSource.fetch ...

app.noteDetail = function(e){
        var view = e.view,
            noteDetailTemplate = kendo.template($("#detailTemplate").text());
 
        app.noteDS.fetch(function(){ //still causing issue to collapse listview
            var item = app.noteDS.get(view.params.id);
            view.scrollerContent.html(noteDetailTemplate(item));
            kendo.bind(view.element, item, kendo.mobile.ui);
        });
    };

any clue?
Petyo
Telerik team
 answered on 21 Jan 2014
9 answers
823 views
Is there a way to do two way binding for the selected item between a view model and a list view.

Currently I get the selected item by doing like below
but I also want if I change the selected item in the ViewModel for it to change in the view.
data-bind="source: MenuItems,
    visible: isVisible,
    events: {change: SectionSelect,}"

var AdminPanelViewModel = kendo.observable(
        {
            // data source
            MenuItems: new kendo.data.DataSource(
            {
               data: [
                        { title: "Alerts", URI: "j", className: "k-widget MainMenuItem_Bogus" },
                        { title: "Nodes", URI: "j", className: "" },
                        { title: "Map", URI: "j", className: "" },
                     ],
            }),
 
            SelectedMenuItem: null,
 
            // visible settings
            isVisible: true,
            selectable: "single",
 
            SectionSelect: function (e) {
                this.set("SelectedMenuItem",e.sender.dataSource.view()[e.sender.select().index()])
            },
        }
    );

Nikolay Rusev
Telerik team
 answered on 21 Jan 2014
Narrow your results
Selected tags
Tags
+? 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?