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

Panel bar custom helper : how to add item

1 Answer 149 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Antoine
Top achievements
Rank 1
Antoine asked on 03 Dec 2014, 08:38 AM
Hello,

I need to make my own helper of panel bar to manage conditional displaying of items.

I made it like this


public static Kendo.Mvc.UI.Fluent.PanelBarBuilder MovementPanel(this HtmlHelper helper, string name, Boolean withContainer,string Controller, RouteValueDictionary export)
{
    Kendo.Mvc.UI.Fluent.PanelBarBuilder myPanel = helper.Kendo().PanelBar()
                                                        .Name(name)
                                                        .ExpandAll(true)
                                                        .ExpandMode(PanelBarExpandMode.Multiple);
 
     
     PanelBarItem itAction = new PanelBarItem();
     itAction.Text = "Actions";
     itAction.Items.Add(NewBarItem("Error detail","javascript:void(0)"));
     itAction.Items.Add(NewBarItem("File content", "javascript:void(0)"));
 
     PanelBarItem itExcel = new PanelBarItem();
     itExcel.Text = "Excel export";
     itExcel.Action("ExportToExcel", Controller, export);
     itAction.Items.Add(itExcel);
     
 
    if (withContainer)
    {
        itAction.Items.Add(NewBarItem("Container history", "javascript:void(0)"));
    }
 
    myPanel.ItemAction(ac => ac.Items.Add(itAction));
    myPanel.Events(events =>
        events.Select("OnSelectAction")
    );
 
 
    return myPanel;
}
 
private static PanelBarItem NewBarItem(string text, string url)
{
    PanelBarItem itTemp = new PanelBarItem();
    itTemp.Text = text;
    itTemp.Url = url;
 
    return itTemp;
}

But how can I link items to the PanelBarBuilder ?

With this instructions : myPanel.ItemAction(ac => ac.Items.Add(itAction));

Method only returns javascript.

thanks for your help

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 05 Dec 2014, 10:01 AM
Hello Antoine,

ItemAction is a function that will be executed for each of the items, it is not a JavaScript function, it is a C# function.

myPanel.ItemAction(x=> {});

Could you please clarify what exactly is the issue that you struggle with, could you please explain a scenario?

Regards,
Petur Subev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
PanelBar
Asked by
Antoine
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or