Telerik Forums
Kendo UI for jQuery Forum
3 answers
1.5K+ views
This should be simple but it appears that the local function cannot be found from a template.  
What's missing?

See  http://jsfiddle.net/JVPa5/2/ 

...
template'#= Simple(OffDuty,OnDuty); #' 
...
function Simple(a,b){
     return 100                     
} 



Rosen
Telerik team
 answered on 02 May 2012
1 answer
258 views
Hi,

In our application we need a swipe function in a listview, that behaves similarly to that of the iphone messages inbox.  So when you swipe to the right (on a item in the listview) it shows a button that allows you to delete the item.

Please advise if there is such a feature available or if it will be available in the future? Otherwise would it be possible to implement our own using the html 5 touchstart and touchmove events? We've had issues trying to implement these side by side with kendo ui mobile...

Thanks
Petyo
Telerik team
 answered on 02 May 2012
1 answer
135 views
Testing in Chrome, using Twitter feed, I am trying to test the 'pullToRefresh' functionality but get this error in Chrome developer tools when I try to pull the list down. :

  1. Uncaught TypeError: Cannot call method 'pullHandled' of undefined
    1. g.extend.refreshkendo.mobile.min.js:2346
    2. e.extend.proxy.gjquery.min.js:538
    3. y.extend.triggerkendo.mobile.min.js:136
    4. o.extend._processkendo.mobile.min.js:1681
    5. o.extend.successkendo.mobile.min.js:1664
    6. e.extend.proxy.gjquery.min.js:538
    7. p.extend.read.c.successkendo.mobile.min.js:1503
    8. f.Callbacks.njquery.min.js:590
    9. f.Callbacks.o.fireWithjquery.min.js:635
    10. f.ajaxTransport.send.d.onload.d.onreadystatechange

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
    <title>My Open Cal</title>
 
    <!-- Kendo UI Files -->
    <link href="styles/kendo.mobile.all.min.css" rel="stylesheet" type="text/css" />
    <script src="js/jquery.min.js" type="text/javascript"></script>
    <script src="js/kendo.mobile.min.js" type="text/javascript"></script>
    <script>
        $( //jQuery page load
            function ()
            {
                var app = new kendo.mobile.Application($(document.body), { layout: "layout", icon: "/images/xboxavatar.png" });
                $("#ulMyCal").kendoMobileListView({
                    appendOnRefresh: true,
                    pullToRefresh: true,
                    pullTemplate: "Pull to refresh",
                    refreshTemplate: "Loading...",
                    dataSource: new kendo.data.DataSource(
                    {
 
                                transport:
                                {
                                    read:
                                    {
                                        url: "http://search.twitter.com/search.json",
                                        contentType: "application/json; charset=utf-8",
                                        type: "GET",
                                        dataType: "jsonp",
                                        data:
                                        {
                                            q: "#tampa"
                                        }
                                    }
                                },
 
                                schema: {
                                    data: "results"
                                     
                                }
                    }),
                    template:"<p>${text}</p>"
 
            });
 
        })
    </script>
</head>
<body>
 
    <!-- Layout for all views in the application, as specified when the app is created -->
    <div data-role="layout" data-id="layout">
      <div data-role="header" >
          <div data-role="navbar">
            <span data-role="view-title">My Test</span>
          </div>
      </div>
      <div data-role="footer">
          <div data-role="tabstrip">
            <a href="#index" data-icon="organize">My Calendar</a>
            <a href="#search" data-icon="search">Search</a>
            <a href="settings.htm" data-icon="settings">Settings</a>
          </div>
     </div>
    </div>
 
 
    <div data-role="view" id="index" data-title = "My Calendar">
        <div style="text-align:center">
            <ul id="ulMyCal" data-style="inset">
             
            </ul>
        </div>
    </div>
 
    <div data-role="view" id = "search" data-title = "Search">
         
    </div>
 
</body>
</html>
Petyo
Telerik team
 answered on 02 May 2012
0 answers
191 views
i used write this: 
  var lpDpt = $("#LpDepth").kendoDropDownList({
                optionLabel: "--Select--",
                dataTextField: "Depth",
                dataValueField: "Depth",
                index: 0,
                dataSource: dsLpDpt,
                animation: false ,
                change: function () {
                    var value = this.value();
                }
            }).data("kendoDropDownList");

but still i'm getting animation. i followed this :http://www.kendoui.com/forums/ui/tabstrip/setting-tab-animation.aspx
if i used the old version js files i'm getting no effects and optional label not displaying so upgraded to latest "kendoui.complete.2012.1.322.trial", then i'm getting optional label and effects by default,i want to disable effects by animation set to 'false' but this was not working.
Tirumalesh
Top achievements
Rank 1
 asked on 02 May 2012
3 answers
101 views
I've created a simple application with phonegap which consists in 2 html files (index.html and about.html) 
Each of these files contains a single <div data-role="view">.
The index.html contains a button (<a href="about.html" data-role="button">)

If I put these files in a webserver they work correctly (the button when clicked navigates to the about.html page). However if I deploy these files through a phonegap application I get the following error message in LogCat (Android 2.2 emulator): TypeError: Result of expression 'd' [undefined] is not an object. at kendo.mobile.min.js:8

The sushi sample application suffered from the same error with it's "About" button when I deployed it through phonegap.

Is there a workaround this issue or any patch available?

Thanks
Petyo
Telerik team
 answered on 02 May 2012
2 answers
279 views
Having dug around in the code, there appear to be two bugs in the kendo core relating to the handling of percentages.

Bug 1: Parsing percentages to floats
The first bug is fairly simple: percentages are mapped to a number between 0 and 1 for percentages 0% to 100%. The bug appears to be in the method kendo.parseFloat(value, culture). When the value is something like "12%" it correctly identifies it as a percentage here:
} else if (value.indexOf(percentSymbol) > -1) {
    number = percent;
    symbol = percentSymbol;
}
however, it subsequently just removes the percentage symbol but doesn't scale the value down by dividing by 100:
value = value.replace("-", "")
             .replace(symbol, "")
             .replace(nonBreakingSpaceRegExp, " ")
             .split(number[","].replace(nonBreakingSpaceRegExp, " ")).join("")
             .replace(number["."], ".");
 
value = parseFloat(value);
 
if (isNaN(value)) {
    value = null;
} else if (negative) {
    value *= -1;
}
 
return value;

This results in a value such as "12%" being changed to "1,200%" when using the percentage formatting such as:
kendo.toString(value, 'P')

Bug 2: Entering fractional percentages
The second problem I've found relates to using fractional percentage values. In my application I need to display percentages to 10dp and have therefore overridden the culture settings as such:
kendo.cultures["en-US"].numberFormat.percent.decimals = 10;
For reference, here's a stripped down version:
$("#grid").kendoGrid({
  autoBind: false,
  dataSource: {
    schema: {
      model: {
          id: "Title",
        fields: {
          Title: { editable: false },
          Percentage: { editable: true, type: "number" }
        }
      }
    }
  },
  columns: [{
    title: "TITLE",
    field: "Title"
  }, {
    title: "PERCENTAGE",
    field: "Percentage",
    format: "{0:P}"
  }],
  editable: true,
  scrollable: false
});
When providing the original model, a value such as 0.003425 is displayed as "0.3425000000%".
When clicking the cell to edit, the number editor simply displays "0".
If I then enter a fractional value such as "0.012345678912", the expected new value in the model should be "1.2345678912%" but is actually rounded to "1.0000000000%" and the value in the underlying model is saved as 0.01

Is there any way we can get more accurate values working in kendo or is there something else limiting us to 2 d.p. in the model?

Thanks in advance,

Daniel

Georgi Krustev
Telerik team
 answered on 02 May 2012
2 answers
273 views
I have a listview uses the selectable property as true, and in the item templateI have a link to remove an item.

But, when I click the link the change event fires first.

Is there a way to know in the change event that the remove was called?
rlapao
Top achievements
Rank 1
 answered on 02 May 2012
0 answers
41 views
Hi! I'm loftconversions and I download your free trial at Mozilla browser. Although the download was successful but I can't open it at Mozilla itself. I need help please?
John8
Top achievements
Rank 1
 asked on 02 May 2012
1 answer
121 views
Hi,

I'm having a problem programmatically creating a grouped list view that looks like this (from the basic listview demo) :

http://www.captainsjob.com/test/cj/images/listscreen.png 

I've created a cut down demo that recreates my problem page in as simple a way as possible. In the real page I'm using Backbone JS and underscore templating. I can't use

new kendo.mobile.Application()

in this case (which works by the way).

Here is the test page showing my problem. The result is a much simpler list with no grouping. It's missing lots of styles but I don't know why :

http://www.captainsjob.com/test/cj/test.html 

Can you have a look and tell me what I'm doing wrong? It doesn't look like the grouped list view

Thanks
Petyo
Telerik team
 answered on 02 May 2012
1 answer
873 views
Hi all,

I need to iterate through the items in a listview and change them programmatically. It's a point-of-sale app that will have to dataSources, one for FundingSources, which will be loaded once at the beginning of the day, and one for "credit cards", which can have mulitiple FundingSources. So each time a get the info for a credit card, it will return a list of funding sources (CardFundings dataSource) for that card and each record will have a FundingSourceID. Based on that FundingSourceID, I want to populate a FundingSourceName field in the FundingSources dataSource.

I can iterate through the the records in the CardFundings dataSource, but how do I iterate through the items in the associated listview and populate them?

Here's the code:

html:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>@ViewBag.Title</title>
 
    @*Kendo*@
    <link href="../../styles/kendo.common.min.css" rel="Stylesheet" />
    <link href="../../styles/kendo.mobile.all.min.css" rel="Stylesheet" />
    <script src="../../js/jquery.min.js" type="text/javascript"></script>
    <script src="../../js/kendo.all.min.js" type="text/javascript"></script>
     
    @*Mine*@
    <script src="../../myJs/Init1.js" type="text/javascript"></script>
    <script src="../../myJs/FundingSources1.js" type="text/javascript"></script>
    <script src="../../myJs/CardFundings1.js" type="text/javascript"></script>
</head>
 
<body>
 
<div id="card-fundings" data-role="view" data-title="Available Funds">
    <div class="head"> </div>
    <h2 id="h2-card-id">Available Funds</h2>
    <ul data-role="listview" data-style="inset" data-type="group">
        <li>
            <ul id="listview-card-fundings">
                <li>Javascript must be</li>
                <li>enabled</li>
            </ul>
        </li>
    </ul>
     <div data-role="footer">
        <div data-role="tabstrip">
            <a id="getCount" data-role="button" data-icon="contacts">Get Count</a>
        </div>
    </div>
</div>
 
    <script id="template-funding-sources" type="text/x-kendo-template">
            <li data-icon="cart"><a href="\#tabstrip-new" class="km-listview-link data-role="listview-link">#= FundingSourceName # #= AvailableBalance #</a></li>
    </script>
 
    <script type="text/javascript">
        $(document).ready(function () {
            init();
        });
    </script>
 
</body>
</html>

And the init() function:

init = function () {
    var kma = new kendo.mobile.Application(document.body);
 
    //android test
    //$("body").removeClass("km-ios").addClass("km-android");
 
    $("#getCount").click(function () {
        enterFundingSourceNames();
    });
 
    getFundingSources();
}

getFundingSources():

FundingSource_Model = kendo.data.Model.define({
    fundingSourceID: "FundingSourceID"
});
  
getFundingSources = function () {
    dsFundingSources = new kendo.data.DataSource({
        transport: {
            read: {
                url: "Home/GetFundingSources",
                dataType: "json"
            }
        },
 
        schema: {
            model: FundingSource_Model
        }
    });
 
    dsFundingSources.read();
 
}
getCardFundings():
CardFunding_Model = kendo.data.Model.define({
    cardID: "CardID"
});
 
getCardFundings = function () {
 
    var templateFundingSources = kendo.template($("#template-funding-sources").html());
 
    dsCardFundings = new kendo.data.DataSource({
        transport: {
            read: {
                url: "/Home/GetCardFundings", // the remove service url
                dataType: "json", // JSONP (JSON with padding) is required for cross-domain AJAX
 
                data: {
                    //additional parameters sent to the remote service
                    _cardId: fundingItem.cardID
                }
            }
        },
 
        schema: {
            model: CardFunding_Model
        },
 
        change: function () { // subscribe to the CHANGE event of the data source
            $("#listview-card-fundings").html(kendo.render(templateFundingSources, this.view()));
        }
    });
 
    dsCardFundings.read();
}
And here's where I need help:
enterFundingSourceNames = function () {
    var thisRecord = null;
    var thisFundingSourceID = null;
    var totCardFundings = dsCardFundings.total();
 
    for (var i = 0; i < totCardFundings; i++) {
        thisRecord = dsCardFundings.at(i);
        thisFundingSourceID = thisRecord.FundingSourceID;
         
//------------------------------------------------------------------------------------------------------
//Here's where I need to iterate through the listview and change the values for CardFundingName
//----------------------------------------------------------------------------------------------------
    };
 
//this doesn't work
    //$("#listview-card-fundings").data("kendoListView").refresh();

}
I know I could do a join operation on the server and retrieve the FundingSourceName that way, but I'm trying to minimize the load on the server, and since the FundingSources will be static all day, I'd rather the mobile app do that work. Also, as vendors add purchases against the various FundingSource AvailableBalances, I'm going to need to update the listview programmatically to reflect what's left in the till for each FundingSource, so no matter what, I'm going to need to update the UI for them. Is there a way to access the listview and update record items programmatically? Thanks, Mike
Petyo
Telerik team
 answered on 02 May 2012
Narrow your results
Selected tags
Tags
+138 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?