@(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>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 }); } }}<!DOCTYPE html>
<html>
<head>
<title></title>
<meta name="validate" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta charset="utf-8">
</head>
<body>
<!-- Validation Tab Page -->
<div data-role="view" id="validatetab" data-title="Validate" data-layout="mobile-tabstrip">
<!-- Venue selection -->
<ul id="venue" data-role="listview" data-style="inset">
<li style="height:40px">
<a href="app/venue.html" class="button" id="venue-button" data-role="button" type="button">Select a Venue</a>
</li>
<li style="height:40px">
<input id="venuevalue" type="text" disabled="true" placeholder="Venue"></input>
</li>
</ul>
<!-- Screening selection -->
<ul id="screening" data-role="listview" data-style="inset">
<li style="height:40px">
<a href="app/screening.html" class="button" id="screeninge-button" data-role="button" type="button">Select a Screening</a>
</li>
<li style="height:40px">
<input id="screeningvalue" type="text" disabled="true" placeholder="Screening"></input>
</li>
</ul>
</div>
<!-- Screening Info Tab Page -->
<div data-role="view" id="infotab" data-title="Information" data-layout="mobile-tabstrip">
<ul id="infolist" data-role="listview" data-style="inset"></ul>
</div>
<script type="text/x-kendo-template" id="infotemplate">
<p class="listvalue">#:infoName#</p>
</script>
<!-- Tab Strip -->
<div data-role="layout" data-id="mobile-tabstrip">
<header data-role="header">
<div data-role="navbar">
<a class="nav-button" data-role="backbutton" data-align="left" href="app/logon.html">Logout</a>
<span data-role="view-title"></span>
<a data-role="button" type="button" data-align="right" data-icon="about" href="app/about.html"></a>
</div>
</header>
<p>TabStrip</p>
<div data-role="footer">
<div data-role="tabstrip" id="tabstrip">
<a href="#validatetab" data-icon="toprated">Validate</a>
<a href="#infotab" data-icon="info">Information</a>
</div>
</div>
</div>
<!-- Styles specific to page -->
<style scoped>
.listvalue
{
float: left;
font-size: medium;
line-height: .5em;
}
</style>
</body>
</html>
I have been researching the topic and had little success on solving the problem. Here is a sample of my code thus far.
View
@(Html.Telerik().Grid<ProductModel.ProductCommentsModel>() .Name("productcomments-grid") .DataKeys(keys => { keys.Add(x => x.Id); }) .DataBinding(dataBinding => { dataBinding.Ajax() .Select("ProductCommentsList", "Product", new { productId = Model.Id }) .Update("ProductCommentUpdate", "Product") .Delete("ProductCommentDelete", "Product"); }) .Columns(columns => { columns.Bound(x => x.Id) .Hidden(true); columns.Bound(x => x.ProductId) .Hidden(true); columns.Bound(x => x.CustomerId) .Hidden(true); columns.Bound(x => x.CustomerName) .Width(200) .ReadOnly(true); columns.Bound(x => x.CreatedDate) .Width(100) .ReadOnly(true); columns.Bound(x => x.LastModifiedDate) .Width(100) .ReadOnly(true); columns.Bound(x => x.Comment); columns.Command(commands => { commands.Edit().ButtonType(GridButtonType.Text); commands.Delete().ButtonType(GridButtonType.Text); }); }) .Editable(edit => edit.Mode(GridEditMode.PopUp)) .EnableCustomBinding(true))public partial class ProductCommentsModel : BaseNopEntityModel { public int ProductId { get; set; } public int CustomerId { get; set; } public string CustomerName { get; set; } [Required(AllowEmptyStrings=true)] [DisplayFormat(NullDisplayText = "", DataFormatString = "0:MM/dd/yyyy")] public DateTime? CreatedDate { get; set; } [Required(AllowEmptyStrings = true)] [DisplayFormat(NullDisplayText = "", DataFormatString = "0:MM/dd/yyyy")] public DateTime? LastModifiedDate { get; set; } public DateTime? SentForRepair { get; set; } public string Comment { get; set; } }function loadTwitterFeed() { var dataSource = new kendo.data.DataSource({ transport: { read: { url: "http://api.twitter.com/1/statuses/user_timeline.json", // the remove service url dataType: "jsonp" // JSONP (JSON with padding) is required for cross-domain AJAX }, parameterMap: function(options) { return { screen_name: "USER_NAME", count: 10, since_id: options.since_id, //additional parameters sent to the remote service max_id: options.max_id //additional parameters sent to the remove service }; } } }); $("#twitter-feed").kendoMobileListView({ dataSource: dataSource, template: $("#twitter-template").text(), appendOnRefresh: true, pullToRefresh: true, //addition parameters which will be passed to the DataSource's read method pullParameters: function(item) { //pass first data item of the ListView return { since_id: item.id_str }; }, endlessScroll: true, //addition parameters which will be passed to the DataSource's next method endlessScrollParameters: function(firstOrigin) { if (firstOrigin) { return { max_id: firstOrigin.id_str }; } } });} $( "#grdTrading" ).kendoGrid( {
dataSource: grddataSource, // static data source
scrollable: true,
height: 180,
columns: [
"Code", "Level",
{
field: "Flag",
template: "#=Flag.Name#",
width: "150px",
editor: TradingDropDownEditor
}
],
editable: true,
sortable: true,
selectable: true
} );
function TradingDropDownEditor( container, options )
{
$( '<input data-text-field="Name" data-value-field="FlagID" id="Category" data-bind="value:' + options.field + '"/>' ).appendTo( container ).kendoDropDownList( {
autoBind: false,
change: function ( e )
{
var grid = $( "#grdTrading" ).data( "kendoGrid" );
var dataItem = null;
grid.select().each( function ( e )
{
dataItem = grid.dataItem( $( this ) );
var id = dataItem.Code;
var DropdownText = dataItem.Flag.Name;
alert( DropdownText );
if ( id == "ABC" && DropdownText == "No" )
{
//Adding dropdown to the second grid
AssociatedData = [{ text: "No", value: "No"}];
$( "#grdAssociated" ).find( "#ddlAssoPort" ).kendoDropDownList( {
dataTextField: "text",
dataValueField: "value",
autoBind: true,
enable: false,
dataSource: AssociatedData
} );
}
else
{
return;
}
} );
},
dataSource: ddlFlag
} );
}
I am able to add the dropdown but on change event if I select the dropdown it vanishes the the dropdown in the other grid.
Please look at the code and please help..!