Telerik Forums
Kendo UI for jQuery Forum
2 answers
711 views
Please help ... 
[1] at the beginning, I create an index.htm file, the template is also defined in the same file.
It works perfectly!!! but the problem is in the second part....

<div id="mydiv">
    <div id="listView" data-role="listview" data-editable="true" data-template="my-template"
         data-bind="source: MySource">
    </div>
</div>
 
<script id="my-template" type="text/x-kendo-template">
    <div>${Status}</div>
    <div>
 
      # if (Status.toUpperCase() == "SINGLE"){#
 
            <img src="imgs/black_acs.png" alt="black_acs image" />
 
      #}else if (Status.toUpperCase() == "MARRIED"){#
 
            <img src="imgs/blue_acs.png" alt="blue_acs image" />
 
       #}else if (Status.toUpperCase() == "OTHER"){#
 
             <img src="imgs/red_acs.png" alt="red_acs image" />
 
       #}#
 
    </div>
</script>
 
<script>
$(document).ready(function ()
            {
        var viewModel = kendo.observable({
           MySource: new kendo.data.DataSource({  // name and status
            transport: {
                      read: {
                        url: "http://xxx.com/REST.VN/AService/GetData",
                        type: "GET",
                        dataType: "json",
                        contentType: "application/json; charset=utf-8",
                        data: function ()
                            {
                                    var jsonParameters = {};
                                jsonParameters.parameter = "XXX";
                                    return jsonParameters;
                            }
                }
             }
        });
 
    kendo.bind($("#mydiv"), viewModel);
});
 
</script>


[2] ... after that, I decide to move the template as external file so that it can be reused by other pages.
I create another file called: template1.tmpl.htm 
This is the content in the file. 
<script id="my-template" type="text/x-kendo-template">
    <div>${Status}</div>
    <div>
 
      # if (Status.toUpperCase() == "SINGLE"){#
 
            <img src="imgs/black_acs.png" alt="black_acs image" />
 
      #}else if (Status.toUpperCase() == "MARRIED"){#
 
            <img src="imgs/blue_acs.png" alt="blue_acs image" />
 
       #}else if (Status.toUpperCase() == "OTHER"){#
 
             <img src="imgs/red_acs.png" alt="red_acs image" />
 
       #}#
 
    </div>
</script>


In the index.html, I create a template loader function as suggested in http://docs.kendoui.com/howto/load-templates-external-files 
on the top of the page: <script src="templateLoader.js"></script>

At the script section, I modify:
<script>
 
$(document).bind("TEMPLATE_LOADED", function (e, data) {
                _itemTemplate = kendo.template($("#my-template").html(), { useWithBlock: false });
                _itemTemplate(data);
                bindMe();
            });
 
$(document).ready(function ()
           {
        templateLoader.loadExtTemplate("template1.tmpl.htm");
            });
 
function bindMe()
{
     var viewModel = kendo.observable({
           MySource: new kendo.data.DataSource({  // name and status
            transport: {
            read: {
            url: "http://xxx.com/REST.VN/AService/GetData",
            type: "GET",
            dataType: "json",
            contentType: "application/json; charset=utf-8",
            data: function ()
                {
                    var jsonParameters = {};
                    jsonParameters.parameter = "XXX";
                return jsonParameters;
                }
            }
         }
    });
 
    kendo.bind($("#mydiv"), viewModel);
}
 
</script>




The result is not showing at all.....
I thought it is not loading the template, so I start debugging. The template is loaded.
(I won't think it is a data issue because it works fine when the template is on the same file.)


Then .... I think something might not correct in the template definition... (it should work fine since it works when template is on the same file)

I removed every thing from the template file:

<script id="my-template" type="text/x-kendo-template">
    <div>fixed text</div>
</script>


This time ... it works with fixed text .... !?!? it becomes interesting....

Then, I start adding data to the template
<script id="my-template" type="text/x-kendo-template"> 
<div>${Status}</div> 
</script> 

Guess what !? ... it is not working ...
After trying ....
<script id="my-template" type="text/x-kendo-template"> 
<div>${data.Status}</div> 
</script> 
It works.... I am able to get the list of Status.

Why do we have to use "data." in the template (external template file)? Previously, the template is defined in the same file, I don't have to put .data in front of field name.
 
Now... conditioning ..
If I remove .toUpperCase(), it works. but I NEED to use the function (and other functions) in the if-else statements.
Since the data can be SiNgle, sinGLE etc.
Why it is not working when I exclude the template from the original file? 
<div>
                  # if (
data.Status.toUpperCase() == "SINGLE"){#
                        <img src="imgs/black_acs.png" alt="black_acs image" />
                  #}else if (
data.Status.toUpperCase() == "MARRIED"){#
                        <img src="imgs/blue_acs.png" alt="blue_acs image" />
                  #}else if (
data.Status.toUpperCase() == "OTHER"){#
                         <img src="imgs/red_acs.png" alt="red_acs image" />
                  #}#
        </div>
 


Please help ....
Jan
Top achievements
Rank 1
 answered on 29 Aug 2012
1 answer
209 views
I know you can set server sider filtering to true or false during configuration but I would like to change this at runtime.

The reason being, if my data set is small enough i want to be able to do filtering client side (as an optimization). If its too large I would like to set it to server side filtering.

Is it possible to change this flag at runtime?
Adrian
Top achievements
Rank 1
 answered on 29 Aug 2012
1 answer
324 views
I am trying to use MVC's model binding functionality. I have  a source that I need to submit to the server and then have it return a value called a Yield to Maturity. The issue is my form is bound to a viewModel. When I do a yieldSource.sync() , the form is submitted with my schema model but nothing is populated. 

Here is my code: Originally I was doing gets in the addYieldValues method but that didn't seem to do anything unless I put the values in an array.

Please help.

$(document).ready(function () {
        
           var viewModel = kendo.observable({
            
           order : {
                   allocations: [],
                   yieldCalcs: [],  
                   TradeDate: "",
                   SettleDate: "",
                   EventType:"",
                   TrustCode: "",
                   Broker: "",  
                   BondProceeds: function(){                                       
                               return this.get("UnderlyingPar") * (this.get("UnderlyingPrice")/100) + this.get("UpfrontFees");
                                       },
                   UnderlyingPar: "",
                   TrustFee: "",
                   RemarkFee: ".",
                   WrapFee: "",
                   LiquidFee: "",
                   BMASIFMA: "",
                   UnderlyingPrice: "",
                   UpfrontFees: "",
                   FloaterAmount:"",
                   InverseFloatPar:"",
                   LeverageRatio: function(){
                       return this.get("FloaterAmount")/this.get("InverseFloatPar");
                   },
                   ResidualYield: function(){
                    
                   },
                   ResidualAmount: "",
                   ResidualPrice: function(){
                       return this.TotalAmount()/this.get("InverseFloatPar")*100;
                   },
                   InterestOnFloat: function(){    
                       return this.get("FloaterAmount")*this.get("BMASIFMA");
                   },
                   InterestOnAssets: function(){
                       return this.get("UnderlyingPar") * this.get("UnderlyingCoupon");
                   },
                   ProgramFees: function(){
                       return (this.get("UnderlyingPar") * (this.get("TrustFee") + this.get("WrapFee"))) + (this.get("FloaterAmount") * (this.get("RemarkFee") +
                       this.get("LiquidFee")));
                   },
                   UnderlyingYield: ".0375",
                   UnderlyingCoupon: ".05",
                   TerminationDate:"",
                   EffectiveCoupon: function(){
                       return  (this.InterestOnAssets() - this.InterestOnFloat() - this.ProgramFees())/this.get("InverseFloatPar");
                   },
 
                   TotalAmount: function(){
                                      return this.get("UnderlyingPar") * (this.get("UnderlyingPrice")/100) - this.get("FloaterAmount");
                                       },
                   ResAccInt: function(){
                   }
            },
            yieldSource: new kendo.data.DataSource({
                      pageSize: 1,
                      data: this.order,                
                      transport: {
                                  read: {                                       
                                      url: "@Url.Action("GetYield","Home")",
                                      dataType: "json"
                                   },
                                  create : {
                                  url: "@Url.Action("GetYield","Home")",
                                      dataType: "json"
                                  }
                      },
                      schema: {                        
                           model: {
                               fields: {
                                   SettleDate:  { Type: "Date", validation: {required: true }},
                                   TerminationDate:  {Type: "Date",  validation: {required: true }},
                                   EffectiveCoupon: { Type: "Number", validation: {required: true }},
                                   ResidualPrice:  { Type: "Number",validation: {required: true }},
                                   EffectiveCoupon: {Type: "Number",validation: {required: true}},
                                   ResidualYield: {Type: "Number",validation: {required: true}},
                                   ResidualPrice: {Type: "Number",validation: {required: true}},
                                   InverseFloatPar: {Type: "Number",validation: {required: true}},
                                   LeverageRatio: {Type: "Number",validation: {required: true}},
                                   UnderlyingPar: {Type: "Number",validation: {required: true}},
                                   UnderlyingPrice: {Type: "Number",validation: {required: true}},
                                   UnderlyingYield: {Type: "Number",validation: {required: true}},
                                   UnderlyingCoupon: {Type: "Number",validation: {required: true}},
                                   EventType: {Type: "Number",validation : {required: true}},
                                   TrustCode: {Type: "Number",validation : {required: true}},
                                   Broker: {Type: "Number",validation : {required: true}},
                                   BondProceeds: {Type: "Number",validation : {required: true}},
                                   BMASIFMA: {Type: "Number",validation : {required: true}},
                                   WrapFee: {Type: "Number",validation : {required: true}},
                                   RemarkFee: {validation : {required: true}},
                                   LiquidFee: {validation : {required: true}},
                                   ResccInt: {validation : {required: true}},
                                   TotalAmount: "TotalAmount"
                                   }
                               }
                           },
                       parameterMap: function(options, operation){
                           if(operation=="create"){
                               console.log(options);
                                 
                                   return { models: kendo.stringify(options.models)};
                           }  
                           return options;                        
                       }
                        
            }),
            addYieldValues: function(){
                 
                    
                   this.yieldSource.add(this.viewModel);
                   this.yieldSource.sync();
                    
               },
Daniel
Telerik team
 answered on 29 Aug 2012
2 answers
152 views
I'm having this problem with Kendo window, I can get the content to show up fine but when I use the call back function to retrieve and populate a div tag in the window, Kendo automatically applies a style of "display:none" to it. Is there a work around for this at all to use a custom message box with kendow window?
Kai
Top achievements
Rank 1
 answered on 29 Aug 2012
4 answers
218 views
Hi,

Just wondering if it's only happening to me, I'm using the gauge for a couple of time and everything went well util I upgrade my kendo version to 2012.2.727 yesterday

Not I got two javascript errors:

Error: Invalid value for <circle> attribute cx="undefined" :81/Desktop/Administration/Dashboard/Widget/Widget.aspx#:1
Error: Invalid value for <circle> attribute cy="undefined"

And I'm able to see a little 'something' on the top left of my gauge (See attachement)
Of course if I look at the generated svg I'm able to see the thing on the top left.

<circle cx="undefined" cy="undefined" r="5.4797" fill-opacity="1" stroke-opacity="1" fill="#ea7001"></circle>

So first is it me only ? Or is it something global ? If yes is there any quick fix ? 
I know its not a blocking thing, but it would be great if I can solve this asap.

Thanks,

Damien

 
Hristo Germanov
Telerik team
 answered on 29 Aug 2012
2 answers
191 views
Hi there,

i suppose my problem is a very trivial one. In order to test the kendo library I wanted to connect the grid to a json webservice.
When that didn't work I tried it locally as described in the examples, but still couldn't make it work.

Is there something I missed? Or is the data in the wrong format? The error firebug tells me is ocurring in kendo.web.js at line 5469 but i suppose the real problem lies much on a higher level.

here the html:

<!DOCTYPE html>
<html lang="de">
<head>
  <meta charset="utf-8" />
  <title>Kendotest</title>
  <!--[if lt IE 9]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  <![endif]--> 
  <link href="styles/kendo.common.min.css" rel="stylesheet" type="text/css" />
  <link href="styles/kendo.default.min.css" rel="stylesheet" type="text/css" />
  <link href="styles/kendo.dataviz.min.css" rel="stylesheet" type="text/css" />
  <script src="js/jquery.min.js" type="text/javascript"></script>
  <script src="js/kendo.web.js" type="text/javascript"></script>
  <script src="js/kendo.dataviz.min.js" type="text/javascript"></script>
  <script src="js/main.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<header>
</header>
<section id="content">
<div id="grid">
</div>
</section>
<footer>
</footer>
</div>
</body>
</html>

and the main.js:

$(document).ready(function(){
var dta = [
{Artikel_ID:1,Bezeichnung:"Testartikel",VK_Preis:900},
{Artikel_ID:2,Bezeichnung:"BASEL GEHT AUS!",VK_Preis:24.5},
{Artikel_ID:3,Bezeichnung:null,VK_Preis:24.5},
{Artikel_ID:4,Bezeichnung:null,VK_Preis:24.5},
{Artikel_ID:5,Bezeichnung:"TESSIN GEHT AUS!",VK_Preis:24.5},
{Artikel_ID:6,Bezeichnung:null,VK_Preis:24.5},
{Artikel_ID:7,Bezeichnung:"Versandkosten",VK_Preis:9},
{Artikel_ID:8,Bezeichnung:"Stein der Verdammnis",VK_Preis:42},
{Artikel_ID:9,Bezeichnung:"Stein der Weisen",VK_Preis:163},
{Artikel_ID:10,Bezeichnung:"Feueressenz der Ewigkeit",VK_Preis:43},
{Artikel_ID:11,Bezeichnung:null,VK_Preis:4740.45},
{Artikel_ID:12,Bezeichnung:null,VK_Preis:252},
{Artikel_ID:13,Bezeichnung:"Eisenbarren",VK_Preis:25},
{Artikel_ID:14,Bezeichnung:null,VK_Preis:1248},
{Artikel_ID:15,Bezeichnung:"Foliant der Erkenntnis",VK_Preis:0},
{Artikel_ID:23,Bezeichnung:"Basisplatine 50mm x50mm, gelocht",VK_Preis:0.8},
{Artikel_ID:24,Bezeichnung:"SMD WIDERSTAND 300R 1% 0805",VK_Preis:0.25},
{Artikel_ID:25,Bezeichnung:null,VK_Preis:0.1},
{Artikel_ID:26,Bezeichnung:"WIDERSTAND,500 OHM 5W Typ: MC14712",VK_Preis:0.25},
{Artikel_ID:27,Bezeichnung:"Kondensator Elektrolyt 45uF, 20V",VK_Preis:1.2},
{Artikel_ID:28,Bezeichnung:"STP0021-1 Steuerungsplatine Flugsicherung",VK_Preis:150}
]


var dsArtikel = new kendo.data.DataSource({
data: dta
});
 
 
$("#grid").kendoGrid({
          dataSource: dsArtikel
 });
  });

any idea what I might be doing wrong here?

thanks for your help,

Graziano
Graziano
Top achievements
Rank 1
 answered on 29 Aug 2012
3 answers
671 views
I have a tree view with check boxes. I am using the checkChildren property to select the children.

I have a bit of code to say how many items are checked. All check boxes have treecheckbox, but only the leaf nodes have itemnode. 

$(".treecheckbox").change(function () {
$("#selected-count").html("Recorded Selected: " + $("#treeview input.itemnode").serializeArray().length);
}); 

The figures come out fine when you click on the leaf nodes. However if you select any of the parent nodes, the count get off. Both the click and the change event for the check boxes fire before the event to update the child nodes. So If I have no records selected  and click a parent that auto selects 5 then the query returns zero until something else fires the event and then the count it right.

Is there any post update event for the check boxes that I can wire to in order to run after that update process fires?

Alternatively, perhaps I am doing it the hard way. Is there a better way of handling it?

Thanks
Randy
Alex Gyoshev
Telerik team
 answered on 29 Aug 2012
1 answer
293 views
I have successfully implemented a custom AJAX validator in a grid for the popup editor. The purpose of the validator is to check whether a login field is unique in a database table. However, in order to do this the server side check the code needs to know the value of the ID field of the model in question so it can exclude itself from the uniqueness check. Is there any way of retrieving the ID, or the value any other field of the model being edited within the custom validator?

A snippet of my code is here:

login:{
type: "string",
validation: {
checkLoginUnique: function(input) {
if ($(input).attr("name") == "login")
{
var result;
$.ajax({
url: "<?php echo Yii::app()->createUrl('/lasso/users/checkUnique'); ?>",
async: false,
data: {
login: $(input).val()
},
success: function(response) {
result = response;
}
});
return result;
}
return true;
}

}
Jacob
Top achievements
Rank 1
 answered on 29 Aug 2012
6 answers
1.3K+ views

Hai

I am creating a MVC4 razor Application using Kendo controls. In my application I supposed to open a view as popup. For that I am using kendow window control.  Am using the below code to open the popup.

@(Html.Kendo().Window()
        .Name("Searchwindow")
    .Title("user Search")
        .LoadContentFrom("../usersearch")  
    .Draggable()
    .Resizable()
    .Width(700)
    .Visible(false)

 The view is open as popup and works fine. But whenever the post action occurs in the view the page is opened as page like http://localhost:4376/usersearch.

I have to show the same popup to the user when the form is posted. How to show the same popup when an action is posted on the view page? Is it possible to open the view as popup after the action completion?


Thanks

Kai
Top achievements
Rank 1
 answered on 29 Aug 2012
0 answers
161 views
I have a menu that I have inserted a grid into.  I use selections in the grid to populate another grid outside of the menu.  All of this is working correctly.

However, I was hit with an extra request of making the items listed in the menu-grid filterable.  I added the tag, but unfortunately, the filter icon does not appear...

I have tried to remove this grid and place it within another area (direct copy/paste, no code change) in the document and the filtering functions correctly.

See attached pictures for extra clarification

I will also note that Sorting works correctly when the grid is inside the menu which makes me think this is in fact a bug and not intentional, but I'm not sure.

For grids within a menu, is the 'filterable()' attribute intentionally neglected?  If so, why and regardless of intentionality, will this change/be fixed in a future release?

Menu Code:
@(Html.Kendo().Menu()
    .Name("ProductBookMenu")
    .OpenOnClick(true)
    .CloseOnClick(true)
    .Items(items =>
    {
        items.Add()
            .Text("Product Book")
            .Content(Html.Partial("ProductBook", Model.ItemModelList).ToHtmlString());
    })
)

Grid Code (ProductBook.cshtml):
@model List<Company.Product.MVC.Models.ItemModel>
@using Kendo.Mvc.UI
 
<script>
function PopulateItemGrid() {
    var productBookGrid = $("#ProductBookGrid").data("kendoGrid");
    var itemGrid = $("#QuoteItemGrid").data("kendoGrid");
 
    productBookGrid.select().each(function () {
        var dataItem = productBookGrid.dataItem($(this));
        itemGrid.dataSource.add(dataItem);
    });
 
    $("#ProductBookMenu").data("kendoMenu").close("#Item1");
}
</script>
 
@(Html.Kendo().Grid(Model)
    .Name("ProductBookGrid")
    .Columns(columns =>
    {
        columns.Bound(i => i.FreightClass).Width(70);
        columns.Bound(i => i.DimensionLength).Width(70);
        columns.Bound(i => i.DimensionWidth).Width(70);
        columns.Bound(i => i.DimensionHeight).Width(70);
        columns.Bound(i => i.DimensionUnitOfMeasure).Width(70);
        columns.Bound(i => i.QuantityQuantityValue).Width(70);
        columns.Bound(i => i.QuantityUnitOfMeasure).Width(70);
        columns.Bound(i => i.WeightWeightValue).Width(70);
        columns.Bound(i => i.WeightUnitOfMeasure).Width(70);
        columns.Bound(i => i.NmfcCode).Width(75);
        columns.Bound(i => i.ItemDescription).Width(150);
    })
    .ToolBar(toolbar =>
    {
        toolbar.Custom().Text("Add").Url("#_").HtmlAttributes(new { onclick = "PopulateItemGrid()" });
    })
    .Pageable()
    .Sortable()
    .Scrollable()
    .Filterable()
    .Resizable(resize => resize.Columns(true))
    .Reorderable(reorder => reorder.Columns(true))
    .DataSource(dataSource => dataSource
        .Ajax()
    )
    .Selectable(selectable => selectable.Mode(GridSelectionMode.Multiple))
)

Jark Monster
Top achievements
Rank 1
 asked on 29 Aug 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
Licensing
ScrollView
Switch
TextArea
BulletChart
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
TimePicker
FloatingActionButton
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
StockChart
ContextMenu
DateTimePicker
RadialGauge
ArcGauge
AICodingAssistant
SmartPasteButton
PromptBox
SegmentedControl
+? more
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?