I am trying to port a Telerik MVC extentions view to a KendoUI view and I am running into a problem.
The view has a grid and a client detail template which also contains a grid. The detail grid is databound (Ajax) to another datasource than the parent grid. In the detail grid I have a client template column. Problem is that in the client template of the detail grid I can only access the fields from the parent grid, not the fields from the detail view grid. This used to work perfectly in the Telerik MVC extentions.
The parent grid
And the detail grid:
In the ClientTemplate of the detail grid I want to access the RoleId and UserId fields of the row but I get the "ReferenceError: RoleId is not defined" message. Scoping it using 'data.RoleId' also does not work because then 'data.RoleId' is replaced with 'undefined'.
Any ideas?
The view has a grid and a client detail template which also contains a grid. The detail grid is databound (Ajax) to another datasource than the parent grid. In the detail grid I have a client template column. Problem is that in the client template of the detail grid I can only access the fields from the parent grid, not the fields from the detail view grid. This used to work perfectly in the Telerik MVC extentions.
The parent grid
@(Html.Kendo().Grid(Model)
.Name("UserManagement")
.DataSource(dataBinding =>
{
dataBinding.Ajax().Read( read => read.Action("_UserManagement", "Account"))
.Create( create => create.Action( "CreateUser", "Account"))
.Model( model => model.Id( u => u.Id ));
})
.ToolBar(commands =>
{
commands.Create().HtmlAttributes(new { @class = "action pie" });
})
.Columns(column =>
{
column.Bound(c => c.Name).Title(ViewResources.UserManagement.Username.ToUpper());
column.Template(@<
text
></
text
>)
.ClientTemplate( "<
input
type
=
'button'
class
=
'action pie'
value='" + ViewResources.UserManagement.ResetPw +
"'
onclick
=
'onResetPassword( #= Id #, \"#= Name #\" )'
/> " +
"<
input
type
=
'button'
class
=
'action pie'
value='" + ViewResources.UserManagement.Delete +
"'
onclick
=
'onDeleteUser( #= Id #, \"#= Name #\" )'
/>")
.HtmlAttributes(new { style = "text-align: center;" })
.Width(400);
})
.Editable(editing => editing.Mode(Kendo.Mvc.UI.GridEditMode.InLine))
.Pageable()
.Sortable()
.Filterable()
.Events(e => e.DataBound("onDataBound"))
.ClientDetailTemplateId("userRoleLinkTemplate")
)
And the detail grid:
<
script
id
=
"userRoleLinkTemplate"
type
=
"text/kendo-tmpl"
>
@(Html.Kendo().Grid<
RoleUserLinkModel
>()
.Name("RoleLinks_#=Id#")
.DataSource(dataSource => dataSource.Ajax().Read( read => read.Action( "_UserRoles", "Account", new { userName = "#= Name #" })))
.Columns(column =>
{
column.Bound(r => r.IsLinked)
.Title("")
.ClientTemplate("<
input
type
=
'checkbox'
class
=
'styled'
name
=
'checkedLinks_#= RoleId #_#= UserId #'
onclick
=
'Urv_onCheckChange(#= RoleId #, #= UserId #, this.checked)'
/>")
.Width(36)
.Sortable(false)
.HtmlAttributes(new { style = "text-align:center" })
.Filterable(false);
column.Bound(r => r.RoleName)
.Title(ViewResources.UserManagement.RoleColumn);
})
.Pageable()
.Sortable()
.Filterable()
.Events(e => e
.DataBound("setupStyling"))
.ToClientTemplate()
)
In the ClientTemplate of the detail grid I want to access the RoleId and UserId fields of the row but I get the "ReferenceError: RoleId is not defined" message. Scoping it using 'data.RoleId' also does not work because then 'data.RoleId' is replaced with 'undefined'.
Any ideas?