This is a migrated thread and some comments may be shown as answers.

Custom toolbar doesn't work properly

1 Answer 214 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
wb
Top achievements
Rank 1
wb asked on 12 Feb 2020, 11:29 AM

The main codes are as follows. When the treelist loaded, Always show alert once. Then click the custom toolbar button, Nothing do!

@(Html.Kendo().TreeList<Liwb.Entities.RulesAndRegulation>
    ()
    .Name("Treelist")
    .Toolbar(toolbar =>
    {
        toolbar.Custom().Name("cust").Text("Upload").Click("uploadfile()");
    })
    .Columns(columns =>
    {
        columns.Add().Field(f => f.Name);
        columns.Add().Field(e => e.ReleaseUnit);
        columns.Add().Field(e => e.ReleaseNumber);
        columns.Add().Field(e => e.EffectiveDate).Format("{0:yyyy/M/d}");
        columns.Add().Field(e => e.Type).Template("#: displayEnum(data)#");
        columns.Add().Width(400).Command(c =>
        {
            c.CreateChild().Text("附件");
            c.Edit();
            c.Destroy();
        }).HtmlAttributes(new
        {
            style = "text-align: center;"
        });
    })
    .Editable()
    .Scrollable(false)
    .Filterable()
    .DataSource(dataSource => dataSource
        .ServerOperation(false)
        .Model(m =>
            {
                m.Id(f => f.ID);
                m.ParentId(f => f.PID);
                m.Field(f => f.Name);
                m.Field(f => f.Pos).DefaultValue(1);
                m.Field(f => f.Type).DefaultValue(Liwb.Utility.RulesAndRegulationType.dc3);
            })
        .Create(create => create.Action("Create", "RulesAndRegulation"))
        .Read(read => read.Action("Read", "RulesAndRegulation"))
        .Update(update => update.Action("Update", "RulesAndRegulation"))
        .Destroy(delete => delete.Action("Destroy", "RulesAndRegulation"))
        )
        .Height(540)
        .Pageable(p => p.PageSize(15)
        .PageSizes(true)
        )
    )
    <script type="text/javascript">
        function uploadfile() {
            alert("My upload!");
        }
    </script>

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 17 Feb 2020, 09:42 AM

Hello,

Thank you for sharing the TreeList declaration.

I examined it and noticed that the Click method receives the execution of uploadfile() function and so the click handler is executed once upon initialization of the component. If the code is modified as below it shall work as expected:

@(Html.Kendo().TreeList<Liwb.Entities.RulesAndRegulation>
    ()
    .Name("Treelist")
    .Toolbar(toolbar =>
    {
        toolbar.Custom().Name("cust").Text("Upload").Click("uploadfile");
    })

Please try this and let me know if anything further arises.

Regards,
Nikolay
Progress Telerik

Get quickly onboarded and successful with Telerik UI for ASP.NET Core with the dedicated Virtual Classroom technical training, available to all active customers.
Tags
TreeList
Asked by
wb
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or