I'm using a row template defined as:
<script type="text/x-kendo-template" id="rowTemp" > <tr id="tr_#= id #" > <td>#= id #</td> <td>#= simbol #</td> <td><input type="checkbox" name="add_#= id #" value="#= id #" id="add_#= id #" class="add" /></td> <td align="center"><input type="button" class="info k-button k-button-icontext" name="info" value="Info" id="info_#= id #" style="height: 26px; margin: 0px 2px; min-width: 64px;" /></td> </tr> </script>
This button when clicked should open a new window.
$(" .info ").click(function (e) { var infowindow = $("#info_win") .kendoWindow({ title: "Info", modal: false, visible: false, resizable: true, width: 300, content: "someContent" }).data("kendoWindow"); infowindow.center.open(); }); In this post states that template should be defined also in the column definition. So my grid looks something like that:
$("#grid").kendoGrid({ dataSource: { data: data, schema: { model: { fields:{ id: { type:"number"}, simbol: { }, add:{} info:{}, } } } columns: [{ field: "add", template:'><input type="checkbox" name="add_#= id #" value="#= id #" id="add_#= id #" class="add" />', title: "Add", }, { field:"info", template: '<input type="button" class="info k-button k-button-icontext" name="info" value="Info" id="info_#= id #" style="height: 26px; margin: 0px 2px; min-width: 64px;" />', title: "", }], rowTemplate: kendo.template($("#rowTemp").html()), }); But buttons are still not working.
Am I missing something? Please help.
"filter":{ "filters":[ {"logic":"or","filters":[ {"field":"NAME","operator":"eq","value":"Rosadi"}, {"field":"NAME","operator":"eq","value":"Rahmat"} ]}, {"logic":"or","filters":[ {"field":"GENDER","operator":"eq","value":"L"}, {"field":"GENDER","operator":"eq","value":"P"} ]} ],"logic":"and"}<?$Filter = $_REQUEST["filter"];if(isset($Filter)){ foreach($Filter["filters"] as $FilterColumn) { $employeeList = $employeeList ->where($FilterColumn['field'], $FilterColumn['value']); }}?>@(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>
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(); });