My TreeList is generally working. However, when a user selects a Custom Command Button, I need to populate the Model with that Group.Id key value. How is this accomplished? As shown, the "function goDetail(e)" code works. However, if I remove the comment the last 2 lines the TreeList doesn't build... of course, I don't get any feedback as to what is wrong. That would be nice. But, this is where I'm trying to pull the dataItem.Id into the Model. How can I get this to happen? Thanks.
<
script
id
=
"icon-template"
type
=
"text/x-kendo-template"
>
<
div
class
=
'group-icon'
style
=
'background-image: url(@Url.Content("#: ImageUrl #"));'
></
div
>
<
div
class
=
'group-name'
>#: Name #</
div
>
</
script
>
@(Html.Kendo().TreeList<
Group
>()
.Name("treelist")
.Columns(columns =>
{
columns.Add().Command(c => { c.Custom().Text("Select")
.Name("selectButton").ClassName("selectButton")
.Click("goDetail"); })
.Width(Glossary.Portal.ButtonWidth);
columns.Add().Field(e => e.Name).TemplateId("icon-template").Width(350);
})
.DataSource(dataSource => dataSource
.Read(read => read.Action("IndexJson", "Groups").Data("getData"))
.ServerOperation(false)
.Model(m =>
{
m.Id(f => f.Id);
m.ParentId(f => f.ParentId);
m.Expanded(true);
m.Field(f => f.Name);
}).Events(events => events.Error("onError"))
)
.Events(evt => evt.DataBound("treeListBound")))
<
script
type
=
"text/javascript"
>
function getData() {
return @Html.Raw(Model.GetIndexData());
}
function goDetail(e) {
e.preventDefault();
alert("goDetail: " + e.toString());
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
alert("goDetail: " + dataItem.id);
@*@Model.Item.GroupId = dataItem.id;
alert("goDetail: " + @Model.Item.GroupId);*@
}
function treeListBound(e) {
var treeList = e.sender;
var items = treeList.items();
for (i = 0; i < items.length; i++) {
var dataItem = treeList.dataItem(items[i]);
.....