I have a need for a grid to be auto updated via ajax on an interval running on multiple platforms. It does not update\refresh on the IPad\IPhone in Safari. I've tested and it works in IE 9 on Win7, Safari 5 on Win7, FireFox on Win7, Android default browser.
I began altering the ajaxbinding example in the Kendo.Mvc.Examples solution. The grid is refreshed every second.
I need to know why it isn't working on IPad\IPhone devices.
ajaxbinding.cshtml:
Here is the modified controller to return data. The GetProducts() method was altered to return random product values.
IndexController.cs:
I began altering the ajaxbinding example in the Kendo.Mvc.Examples solution. The grid is refreshed every second.
I need to know why it isn't working on IPad\IPhone devices.
ajaxbinding.cshtml:
@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.ProductViewModel>() .Name("Grid") .Columns(columns => {columns.Bound(p => p.ProductID).Groupable(false).Width(140);columns.Bound(p => p.ProductName);columns.Bound(p => p.UnitPrice).HtmlAttributes(new { style = "text-align: right" }).Width(140);columns.Bound(p => p.UnitsInStock).Width(160);}).Pageable() .Sortable() .Scrollable().Selectable(row => row.Mode(GridSelectionMode.Single).Type(GridSelectionType.Cell)) .Groupable() .DataSource(dataSource => dataSource.Ajax().Read(read => read.Action("Products_Read", "Grid"))))<button id="refreshButton" onclick="refreshGrid()">Start the Refresh</button><script> var myGrid; $(function () { myGrid = $('#Grid').data('kendoGrid'); }); function refreshGrid() { $('#refreshButton').attr("disabled", "disabled"); setInterval(DoWork, 1000); } function DoWork() { myGrid.dataSource.read(); }</script>Here is the modified controller to return data. The GetProducts() method was altered to return random product values.
IndexController.cs:
using System.Collections.Generic;using System.Data.Linq;using System.Linq;using System.Web.Mvc;using Kendo.Mvc.Examples.Models;using Kendo.Mvc.Extensions;using Kendo.Mvc.UI;using System;namespace Kendo.Mvc.Examples.Controllers{ public partial class GridController : Controller { public ActionResult Index() { return View(GetProducts()); } public ActionResult Remote_Data() { return View("AjaxBinding"); } public ActionResult Products_Read([DataSourceRequest] DataSourceRequest request) { return Json(GetProducts().ToDataSourceResult(request), JsonRequestBehavior.AllowGet); } private static IEnumerable<OrderViewModel> GetOrders() { var northwind = new NorthwindDataContext(); var loadOptions = new DataLoadOptions(); loadOptions.LoadWith<Order>(o => o.Customer); northwind.LoadOptions = loadOptions; return northwind.Orders.Select(order => new OrderViewModel { ContactName = order.Customer.ContactName, OrderDate = order.OrderDate, OrderID = order.OrderID, ShipAddress = order.ShipAddress, ShipCountry = order.ShipCountry, ShipName = order.ShipName, EmployeeID = order.EmployeeID }); } private static IEnumerable<ProductViewModel> GetProducts() { //var northwind = new NorthwindDataContext(); var list = new List<ProductViewModel>(); var randomGen = new Random(DateTime.Now.Second); for (var i = 500; i >= 1; i--) { list.Add( new ProductViewModel { ProductID = i, ProductName = "ProductName-" + i, UnitPrice = Convert.ToDecimal(randomGen.NextDouble()), UnitsInStock = randomGen.Next(), UnitsOnOrder = (short)randomGen.Next(), Discontinued = (i % 2) == 0 , LastSupply = DateTime.Today.AddDays(i) } ); } return list.AsEnumerable(); //return northwind.Products.Select(product => new ProductViewModel //{ // ProductID = product.ProductID, // ProductName = product.ProductName, // UnitPrice = product.UnitPrice ?? 0, // UnitsInStock = product.UnitsInStock ?? 0, // UnitsOnOrder = product.UnitsOnOrder ?? 0, // Discontinued = product.Discontinued, // LastSupply = DateTime.Today //}); } private static IEnumerable<EmployeeViewModel> GetEmployees() { var northwind = new NorthwindDataContext(); return northwind.Employees.Select(employee => new EmployeeViewModel { EmployeeID = employee.EmployeeID, FirstName = employee.FirstName, LastName = employee.LastName, Country = employee.Country, City = employee.City, Notes = employee.Notes, Title = employee.Title, Address = employee.Address, HomePhone = employee.HomePhone }); } }}