Telerik Forums
Kendo UI for jQuery Forum
2 answers
182 views
Hi,

I am currently trying to get the following snippet of code from your Kendo MVC examples project to work. Unfortunately it seems as though having logic in the ClientTemplate on a column (ShipName) in the child grid(in the kendo-templ) causes issues. Any ideas how to get around this?

All help will be massively appreciated.

Jean Hibbert

@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.EmployeeViewModel>()
        .Name("Employees")
        .Columns(columns =>
        {
            columns.Bound(e => e.FirstName).Width(140);
            columns.Bound(e => e.LastName).Width(140);
            columns.Bound(e => e.Title).Width(200);
            columns.Bound(e => e.Country).Width(200);
            columns.Bound(e => e.City);
        })
        .ClientDetailTemplateId("employeesTemplate")
        .Pageable()
        .DataSource(dataSource => dataSource
            .Ajax()
            .Read(read => read.Action("HierarchyBinding_Employees""Grid"))
            .PageSize(5)
        )
        .Sortable()
        .Events(events => events.DataBound("dataBound"))
)

<script id="employeesTemplate" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.OrderViewModel>()
            .Name("Orders_#=EmployeeID#")
            .Columns(columns =>
            {
                
                columns.Bound(o => o.OrderID).Width(101);
                columns.Bound(o => o.ShipCountry).Width(140);
                columns.Bound(o => o.ShipAddress).Width(200);
                
                columns.Bound(o => o.ShipName)
                .ClientTemplate("#= ShipName? 'XXX' : 'YYY' #")
                .Width(200);
            })
            .DataSource(dataSource => dataSource
                .Ajax()
                .Read(read => read.Action("HierarchyBinding_Orders""Grid"new { employeeID = "#=EmployeeID#" }))
            )
            .Pageable()
            .Sortable()
            .ToClientTemplate()
    )
</script>
<script>
    function dataBound() {
        this.expandRow(this.tbody.find("tr.k-master-row").first());
    }
</script>

Jean
Top achievements
Rank 1
 answered on 14 Sep 2012
8 answers
384 views
These seems to be an issue with using MVVM binding for a mobile app  as I took the web example Web MVVM remote-binding and just changed the libraries to:

script src="../js/jquery.min.js"></script>
<script src="../js/kendo.mobile.min.js"></script>
<script src="../js/kendo.binder.min.js"></script>

Now in Google Chrome debugger I see the exception:
Uncaught ReferenceError: ProductID is not defined

As I look in Fiddler I see that the service (JSONP) call was never issued and must
believe this is the issue. Hopefully MVVM binding can be made to work in
the mobile app as I am evaluating Kendo against Sencha Touch which has
 a wonderful built in MVC pattern. I will not let code be written here
 without use of patterns like MVC abd MVVM so this is not a nice feature
 but a requirement in our choice.

I then made a couple of changes to the code that seemed promising:

1. I added a statement to force the read after the viewModel definition

 

viewModel.productsSource.read();
    Now I see the JSON data in Fiddler with the ProductID but still get the same error. Now I understand that
the datasource should contain observables which should cause the data binding to occur when the JSON data is read. This does not seem to be happening so I added a change method to the datasource that fires wnen the data has been read.It looks like:
change:function() {
       kendo.bind($("#form-container"), viewModel);
},
Now I place a breakpoint on this line and it is hit and the same exception is occuring, hopefully I am missing the obvious! The complete code looks like (HTML is unchanged from example)

var crudServiceBaseUrl = "http://demos.kendoui.com/service";
 
       $(document).ready(function() {
           var viewModel = kendo.observable({
               productsSource: new kendo.data.DataSource({
                   transport: {
                       read: {
                           url: crudServiceBaseUrl + "/Products",
                           dataType: "jsonp"
                       },
                       update: {
                           url: crudServiceBaseUrl + "/Products/Update",
                           dataType: "jsonp"
                       },
                       destroy: {
                           url: crudServiceBaseUrl + "/Products/Destroy",
                           dataType: "jsonp"
                       },
                       parameterMap: function(options, operation) {
                           if (operation !== "read" && options.models) {
                               return {
                                   models: kendo.stringify(options.models)
                               };
                           }
                           return options;
                       }
                   },
                    change: function() {
                       kendo.bind($("#form-container"), viewModel);
                   },
                   batch: true,
                   schema: {
                       model: {
                           id: "ProductID"
                       }
                   }
               }),
               selectedProduct: null,
               hasChanges: false,
               save: function() {
                   this.productsSource.sync();
                   this.set("hasChanges", false);
               },
               remove: function() {
                   if (confirm("Are you sure you want to delete this product?")) {
                       this.productsSource.remove(this.selectedProduct);
                       this.set("selectedProduct", this.productsSource.view()[0]);
                       this.change();
                   }
               },
               showForm: function() {
                  return this.get("selectedProduct") !== null;
               },
               
           });
           viewModel.productsSource.read();
           
       });

 

 

 

 

 

 


 


john
Top achievements
Rank 1
 answered on 14 Sep 2012
1 answer
5.5K+ views
Hi,
I need to insert a link to a phone number and I want that on click event automatically start the call.

In Jquery I use <a href="tel:00-00-000-000" >00-00-000-000</a>

Thanks a lot
Mauro

Ali
Top achievements
Rank 1
 answered on 14 Sep 2012
3 answers
105 views
Good morning,

I am testing the KendoUI Mobile framework in combination with trigger.io
The point is that it shows the background but nothing else.
Then when touching  the screen the Layout/View appears (thats only happening on the the device, not on emulator)
the content also appears when you turn the mobile to landscape.

Some idea why it happens? Any idea to make a workaround (calling some kind of function in data-show per example)??

Best regards!
<!DOCTYPE html>
<html>
<head>
    <title>Test Runner</title>
    <link href="css/kendo.mobile.all.min.css" rel="stylesheet" />
     <script src="js/includes/jquery.min.js"></script>
    <script src="js/includes/kendo.mobile.min.js"></script>
</head>
<body>
    <div data-role="view" data-layout="default" id="default">
        Hello Mobile World!
    </div>
 
    <div data-role="layout" data-id="default">
        <div data-role="header">
            test runner
        </div>
    </div>
    
    
    <script>
 
        window.kendoMobileApplication = new kendo.mobile.Application(document.body, { platform: 'android' }, {
            viewShow: function (e) {
                var viewID = e.view.element.attr("id");
            }
        });
 
 
 
     
 
    </script>
</body>
</html>
Ali
Top achievements
Rank 1
 answered on 14 Sep 2012
0 answers
92 views
Hi, i'm from Peru its my english is poor.
But, how puts name in iframe for window, whit from code:

     var onClose = function() {
         undo.show();
    }

    function onRefresh(e) {

    }

var window2 = $("#window2"),
        undo2 = $("#node_pjpersons").bind("dblclick", function(){
                    window2.data("kendoWindow").center().open();
        });

    if (!window2.data("kendoWindow")) {
        window2.kendoWindow({
            actions: ["Refresh", "Close"],
            width: "615px",
            height:"600px",
            title: "Mis Proyectos",
            visible:false,
            content: "/node/personal-project/",
            resizable: false,
            refresh: onRefresh,
            iframe: true,
            close: onClose
        });
    }

Jorge
Top achievements
Rank 1
 asked on 14 Sep 2012
6 answers
1.5K+ views
Let's say I have a Grid that maps to a Model.  I'd like to add another column which gets data from a second Data Source.  Any idea if this can be done, and what is the best way to go about it?

Thanks
Arturo
Top achievements
Rank 1
 answered on 14 Sep 2012
1 answer
136 views
I want to  display a grid  when a link inside a ListView is clicked . I'm using a template for the ListView.

Html:
<div id="listView" ></div>

<div id="grid" ></div>

Template:

<script type="text/x-kendo-tmplate" id="template">
    <div>
             <ul>
                     <li><a class="list k-link" title="#= title #" id="#= id#" >#= name #</a></li>
                </ul>
    </div>
</script>

I tried to do this using following code but nothing happens. Only id is read correctly but the request is not made.

$(" .list").live({click:function(){
 
    var id=$(this).attr('id');

    $("#grid").kendoGrid({
           dataSource: {
                 transport: {
                        read: "somefile.php?id="+id,  
                 },
               schema: {
                         data:"data",
                          model: {
                               id: "id_pf",
                               fields:{
                                    first:{}, 
                                   second:{}
                               }
                        }
              },
             total: function(response) {
                      return $(response.data).length;
             },

            pageSize: 10
         },

         columns: [
                 { title: "First", field: "first"},
                { title: "Second", field: "second"},
            ]
       });

}});

Vladimir Iliev
Telerik team
 answered on 14 Sep 2012
6 answers
970 views
How do I disable dragging after the draggable hits its target?
Nohinn
Top achievements
Rank 1
 answered on 14 Sep 2012
1 answer
408 views
I have columns a and column b in our grid,   and instead of average of b, I want SUM(A*B)/Sum(B) to show up in the group by aggregate to give me the weigthed average.

Is there a way to do this with Kendo UI Grid.  Please give an example if you have done this before.

Thanks

Alexander Valchev
Telerik team
 answered on 14 Sep 2012
7 answers
1.8K+ views
Well like everyone, I'm trying to get my window to open in the center the first time it's loaded. 

Initially, I was completely confused as to why the window wasn't opening int he center since I had copied the code exactly. 

function ShowKendoWindow(link) {
        var title = link.getAttribute("WindowCaption");
        var url = link.getAttribute("WindowURL");
        var win = $(".modal-window");
        if (!win.data("kendoWindow")) {
            // window not yet initialized
            win.kendoWindow({
                animation: {
                    open: {
                        effects: { fadeIn: {} },
                        duration: 200,
                        show: true
                    },
                    close: {
                        effects: { fadeOut: {} },
                        duration: 200,
                        hide: true
                    }
                },
                content: url,
                title: title,
                draggable: true,
                modal: true,
                resizable: false,
            }).data("kendoWindow").center().open();
        }
        else {
            // reopening window
            win.data("kendoWindow")
            .refresh(url) // request the URL via AJAX
            .title(title)          
            .center().open() // open the window;
        }
        event.preventDefault();
    }
    

So, what I realized is happening is that the window loads in the center while it's waiting for the content to load via ajax. Once it loads via ajax, it doesn't move the window to the center, it expands from the top left corner to fit the content of the page that it's loading.

Now what we've done( and the reason we aren't using a fixed height/width) is that we have have one function we add to the click so that we can load all kinds of different content in there and we don't have to worry about the window looking lost in a big open div or having scrolling content. 

So, my question, is there any way to get the window to load AFTER the content loads. Or is there some other way tot get it to center itself again after the content loads? This isn't a huge deal, but it's something we'd definitely like to fix.

I've attached some screen shots for you to see what is happening.

Thanks in advance for any help.
Majid
Top achievements
Rank 1
 answered on 14 Sep 2012
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
Breadcrumb
Collapsible
Localization
MultiViewCalendar
Touch
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
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
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?