or
@(Html.Kendo().ComboBoxFor(model => model.CountryId)
.Filter(FilterType.Contains)
.BindTo(ViewBag.Countries)
.HtmlAttributes(CommonHelpers.MergeHtmlAttributes(Html.GetUnobtrusiveValidationAttributes(
CommonHelpers.GetPropertyName(() => Model.CountryId)),
new Dictionary<
string
, object>(){
{ "class", "combobox-country" }})))
<
div
>
@(Html.Kendo().Grid(Model.UnitDetails)
.Name("Grid")
.DataSource(ds => ds
.Ajax()
.Read(read => read.Action("Index", "Home"))
)
.HtmlAttributes(new { style = "height:430px;" })
.Columns(columns =>
{
columns.Bound(p => p.UnitContract.Name).Title("Unit");
columns.Bound(p => p.UnitContract.CurrentRun.Operation.WellContract.Location).Title("Site");
columns.Bound(p => p.UnitContract.CurrentRun.Operation.WellContract.Name).Title("Well");
columns.Bound(p => p.UnitContract.CurrentRun.Id).Title("Run");
columns.Bound(p => p.UnitContract.CurrentRun.RunTask).Title("Task");
columns.Bound(p => p.UnitContract.CurrentRun.Operation.Description).Title("Operation");
columns.Bound(p => p.UnitContract.Status.StatusText).Title("Status");
columns.Bound(p => p.UnitContract.CurrentRun.LatestWellLogEntry.Depth).Title("Depth (m)");
columns.Bound(p => p.UnitContract.CurrentRun.LatestWellLogEntry.Speed).Title("Speed (m/min)");
columns.Bound(p => p.UnitContract.CurrentRun.LatestWellLogEntry.Tension).Title("Weight (kg)");
columns.Bound(p => p.UnitContract.CurrentRun.Name);
columns.Template(p => { }).ClientTemplate(" ").Width(75);
})
.ClientRowTemplate(Html.Partial("_ClientRowTemplate", Model).ToHtmlString())
.Pageable()
.Scrollable(builder => builder.Height(250))
.Sortable())
</
div
>
<
tr
>
<
td
>#: UnitContract.Name#
</
td
>
<
td
>#: UnitContract.CurrentRun.Operation.WellContract.Location#
</
td
>
<
td
>#: UnitContract.CurrentRun.Operation.WellContract.Name#
</
td
>
<
td
>#: UnitContract.CurrentRun.Id#
</
td
>
<
td
>#: UnitContract.CurrentRun.RunTask#
</
td
>
<
td
>#: StatusMessage#
</
td
>
<
td
class
=
'text-center'
>
<
span
class
=
'label label-#:StatusColor #'
style
=
'width: 25px;'
> </
span
>
</
td
>
<
td
>
<
div
>
@(Html.Kendo().Sparkline()
.Name("depth")
.Data(#: UnitContract.CurrentRun.LatestWellLogEntry.Speed#)
.Type(SparklineType.Bar)
.Tooltip(false)
.ValueAxis(axis => axis.Numeric().Max(5000).Min(-5000).Visible(false))
.CategoryAxis(c =>
c.MajorTicks(ticks => ticks.Visible(false))
.Visible(true))
.ChartArea(ca => ca.Background("transparent"))
.HtmlAttributes(new { style = "width: 75px;" }))
</
div
>
</
td
>
<
td
>
<
div
>
<!-- DataWiz Sparkline -->
</
div
>
</
td
>
<
td
>
<
div
>
<!-- DataWiz Sparkline -->
</
div
>
</
td
>
<
td
>#: UnitContract.CurrentRun.Name#
</
td
>
<
td
>
<
form
method
=
'POST'
action
=
'@Url.Content("~/UnitDetails/Index/")#: UnitContract.Id#'
>
<
input
type
=
'submit'
class
=
'k-button'
value
=
'Details'
/>
</
form
>
</
td
>
</
tr
>
@(Html.Kendo().Grid(Of KendoUIMvcApplication1.ViewModels.EmployeeViewModel).Name("Employees") _
.Columns(Sub(columns)
columns.Bound(Function(e) e.FirstName).Width(140)
columns.Bound(Function(e) e.LastName).Width(140)
columns.Bound(Function(e) e.Title).Width(200)
columns.Bound(Function(e) e.Country).Width(200)
columns.Bound(Function(e) e.City)
End Sub) _
.ClientDetailTemplateId("employeesTemplate") _
.Pageable() _
.DataSource(Sub(dataSource)
dataSource.Ajax().Read(Sub(read)
read.Action("HierarchyBinding_Employees", "Example")
End Sub)
dataSource.Ajax().PageSize(5)
End Sub) _
.Sortable() _
.Events(Sub(events)
events.DataBound("dataBound")
End Sub))
<
script
id
=
"employeesTemplate"
type
=
"text/kendo-tmpl"
>
@(Html.Kendo().Grid(Of KendoUIMvcApplication1.ViewModels.OrderViewModel).Name("Orders_#=EmployeeID#") _
.Columns(Sub(columns)
columns.Bound(Function(o) o.OrderID).Width(101)
columns.Bound(Function(o) o.ShipCountry).Width(140)
columns.Bound(Function(o) o.ShipAddress).Width(200)
columns.Bound(Function(o) o.ShipName).Width(200)
End Sub) _
.DataSource(Sub(dataSource)
dataSource.Ajax().Read(Sub(read)
read.Action("HierarchyBinding_Orders", "Example", New With {.employeeID = "#=EmployeeID#"})
End Sub)
End Sub) _
.Pageable() _
.Sortable() _
.ToClientTemplate())
</
script
>
<
script
>
function dataBound() {
this.expandRow(this.tbody.find("tr.k-master-row").first());
}
</
script
>
Imports System.Web.Mvc
Imports System.Linq
Imports System.Data.Linq
Imports Kendo.Mvc.Extensions
Imports Kendo.Mvc.UI
Public Class ExampleController
Inherits System.Web.Mvc.Controller
Public Function Hierarchy() As ActionResult
Return View()
End Function
Public Function HierarchyBinding_Employees(<
DataSourceRequest
> request As DataSourceRequest) As ActionResult
Return Json(GetEmployees().ToDataSourceResult(request))
End Function
Public Function HierarchyBinding_Orders(employeeID As Integer, <
DataSourceRequest
> request As DataSourceRequest) As ActionResult
Return Json(GetOrders().Where(Function(order) order.EmployeeID = employeeID).ToDataSourceResult(request))
End Function
Private Shared Function GetOrders() As IEnumerable(Of ViewModels.OrderViewModel)
Dim northwind = New NorthwindDataContext()
Dim loadOptions = New DataLoadOptions()
loadOptions.LoadWith(Of Order)(Function(o) o.Customer)
northwind.LoadOptions = loadOptions
Return northwind.Orders.[Select](Function(order) New ViewModels.OrderViewModel() With { _
.ContactName = order.Customer.ContactName, _
.OrderDate = order.OrderDate, _
.OrderID = order.OrderID, _
.ShipAddress = order.ShipAddress, _
.ShipCountry = order.ShipCountry, _
.ShipName = order.ShipName, _
.EmployeeID = order.EmployeeID _
})
End Function
Private Shared Function GetProducts() As IEnumerable(Of ViewModels.ProductViewModel)
Dim northwind = New NorthwindDataContext()
Return northwind.Products.[Select](Function(product) New ViewModels.ProductViewModel() With { _
.ProductID = product.ProductID, _
.ProductName = product.ProductName, _
.UnitPrice = If(product.UnitPrice, 0), _
.UnitsInStock = If(product.UnitsInStock, 0), _
.UnitsOnOrder = If(product.UnitsOnOrder, 0), _
.Discontinued = product.Discontinued, _
.LastSupply = DateTime.Today _
})
End Function
Private Shared Function GetEmployees() As IEnumerable(Of ViewModels.EmployeeViewModel)
Dim northwind = New NorthwindDataContext()
Return northwind.Employees.[Select](Function(employee) New ViewModels.EmployeeViewModel() With { _
.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 _
})
End Function
End Class
"<
div
class
=
"k-widget k-tabstrip k-header"
id
=
"Inty#=Id#"
><
ul
class
=
"k-reset k-tabstrip-items"
><
li
class
=
"k-item k-state-default"
><
a
class
=
"k-link"
href
=
"\#Inty#=Id#-1"
>Turtle</
a
></
li
></
ul
><
div
class
=
"k-content"
id
=
"Inty#=Id#-1"
>Brownie</
div
></
div
><
script
><
br
><
span
class
=
"Apple-tab-span"
style
=
"white-space:pre"
> </
span
>jQuery(function(){jQuery("\#Inty#=Id#").kendoTabStrip({});});<
br
><\/script>"
<
script
id
=
"jobGridTemplate"
type
=
"text/kendo-tmpl"
>
@(Html.Kendo().TabStrip().Name("Inty#=Id#").Items( items => items.Add().Text("Turtle").Content(@<
text
>Brownie</
text
>) ).ToClientTemplate())
</
script
>
@(
Html.Kendo().Grid<
JobGridViewModel
>()
.Name("Grid")
.ClientDetailTemplateId("jobGridTemplate")
.Columns(columns =>
{
columns.Bound(p => p.Id).Hidden();
columns.Bound(p => p.Name).Width("15em").ClientTemplate(Html.ActionLink("#=Name#", "Edit", new {selectedjobid = "#=Id#"}).ToHtmlString());
columns.Bound(p => p.Number).Width("11em");
columns.Bound(p => p.Cost).Width("12em");
columns.Bound(p => p.Status).Template(@<
text
>
@item.Status;
</
text
>)
.ClientTemplate("#= statusValues[Status] #")
.EditorTemplateName("JobStatusEditor").Width("9em");
columns.Bound(p => p.Date).Width(130).Format("{0:d}").EditorTemplateName("Date");
columns.Bound(p => p.Commissions).Filterable(false).Template(@<
text
>
@ListCommission(item, CommissionType.Sell)
</
text
>).EditorTemplateName("ClientCommission").ClientTemplate("#= template(data.Commissions) #").Sortable(false);
columns.Command(command =>
{
command.Edit();
command.Destroy();
command.Custom("Duplicate").Text("Copy").SendDataKeys(true).SendState(true).Click("onGridCommand");
}).Width(280);
}).ToolBar(y=> y.Template(
@<
text
>
<
div
>
Job Name
@(Html.Kendo().AutoComplete().Name("SearchName").DataSource(source =>
{
source.Read(read => read.Action("_GetJobNamesLike", "Jobs" })
.Events(events => events.Change("onFilterChange")))
</
div
>
<
div
>
Job Number
@(Html.Kendo().AutoComplete().Name("SearchNumber")
.DataSource(binding =>
{
binding.Read(read => read.Action("_GetJobNumbersLike", "Jobs"));
}).Events(events => events.Change("onFilterChange")))
</
div
>
@item.CustomCommandToolBarButton("NewJob", "New Job", "New", "Jobs", null)
</
text
>))
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Sortable()
.Pageable(paging => paging.PageSizes(new int[]{20,40,60,80}))
.Scrollable(config => config.Height(1000).Virtual(true))
.Resizable(resize => resize.Columns(true))
.Filterable()
.DataSource( dataBinding =>
dataBinding.Ajax().Events(e =>
{
e.RequestStart("onGridDataBinding"); // try Ajax().Data("sendData") return { foo: "bar" };
}).Model(model => model.Id(id => id.Id))
.Read(read=>read.Action("_SelectAjaxEditing", "Jobs", new {jobName="", jobNumber=""}))
.Create(create => create.Action("_InsertAjaxEditing", "Jobs"))
.Update(update => update.Action("_SaveAjaxEditing", "Jobs"))
.Destroy(destroy=>destroy.Action("_DeleteAjaxEditing", "Jobs")))
.Events(events =>
{
events.Change("onGridEdit").DataBound("onRowDataBound")
.DetailExpand("onGridExpand")
.DetailCollapse("onGridCollapse");
})
)
I am eager to see this product in action but this small issue would be a show stopper for me for switching over the rest of my code base.