How To

Render Toolbar from code behind

Toolbar can be rendered from the code behind by initializing the required properties in controller and passing those properties via ViewData or Model to the client side

The following code illustrates the rendering of Toolbar using Toolbar properties from code behind.

@{ 
         Html.EJ().Toolbar("toolbar", (Syncfusion.JavaScript.Models.ToolbarProperties)ViewData["toolbar"]).Render();
       }
public ActionResult Index()
        {
            List<ToolbarBaseItem> obj = new List<ToolbarBaseItem>();
            obj.Add(new ToolbarBaseItem() { SpriteCssClass= "e-icon e-cut" ,TooltipText="cut"});
            obj.Add(new ToolbarBaseItem() { SpriteCssClass = "e-icon e-copy", TooltipText = "copy" });
            obj.Add(new ToolbarBaseItem() { SpriteCssClass = "e-icon e-paste", TooltipText = "paste" });
            ToolbarProperties toolbar = new ToolbarProperties();
            toolbar.Items = obj;
            ViewData["toolbar"] = toolbar;
            return View();
        }