- Home
- Forum
- ASP.NET MVC
- Create components,attributes and events in controller
Create components,attributes and events in controller
Hi,
I tried to create treegrid's toolbar item in controller:
Syncfusion.JavaScript.Models.TreeGridToolBarOptions o = new Syncfusion.JavaScript.Models.TreeGridToolBarOptions();
o.ShowToolbar = true;
o.ToolbarItems = new List<String>() { "add", "edit", "delete", "update", "cancel", "expandAll", "collapseAll" };
List<Syncfusion.JavaScript.Models.TreeGridCustomToolbarItem> cusI = new List<Syncfusion.JavaScript.Models.TreeGridCustomToolbarItem>();
Syncfusion.JavaScript.Models.TreeGridCustomToolbarItem a = new Syncfusion.JavaScript.Models.TreeGridCustomToolbarItem();
a.Text = "Refresh";
a.TemplateID = "ValidateTemplate";
a.TooltipText = "refresh";
cusI.Add(a);
o.CustomToolbarItems = cusI;
ViewBag.toolbarSettings = o;
Also added in view cshtml file:
*toolbar-settings="ViewBag.toolbarSettings" in <ej-tree-grid ...
*<script id="ValidateTemplate" type="text/x-jsrender"
<a class="e-toolbaricons e-icon refrech" /
</script
And it actually worked, but still have few question:
*I did find "Syncfusion.JavaScript.TreeGrid", I guess I can even create my treegrid in controller but didn't find Syncfusion.JavaScript.Grid or Syncfusion.JavaScript.TextBox
*refrech icon is not visible, I copied "class="e-toolbaricons e-icon refrech" from help.sync
*Is it possible to, when I click on that CustomToolbarItem named refrech, one of my treegrid column become hidden (event coded in controller)
*Is there any documentations on how to create components in controller ?
Regards,
Kalai Sirajeddine
SIGN IN To post a reply.
1 Reply
PE
Punniyamoorthi Elangovan
Syncfusion Team
February 23, 2018 02:01 PM UTC
Hi Kalai Sirajeddine,
Please find the updates below,
Query1: I did find "Syncfusion.JavaScript.TreeGrid", I guess I can even create my treegrid in controller but didn't find Syncfusion.JavaScript.Grid
or Syncfusion.JavaScript.TextBox
Answer:
For grid the problem will occurs only when we doesn’t refer the Syncfusion.JavaScript.Models in the view page. So we suggested you to define the namespace like one of the below given example:-
|
@using Syncfusion.JavaScript.Models;
@(Html.EJ().Grid<object>("FlatGrid")
.Datasource((IEnumerable<object>)ViewBag.dataSource)
.AllowPaging()
.Columns(col =>
{
col.Type("checkbox").Width(50).Add();
col.Field("Freight").HeaderText("Freight").EditType(EditingType.Numeric).NumericEditOptions(newEditorProperties() { DecimalPlaces = 2 }).Add();
})
) |
For Textbox currently we don’t have the textbox component separately. So can you please share the usage of textbox in your application. It will be very helpful for us to understand your requirement clearly.
Query 2: Is it possible to, when I click on that CustomToolbarItem named refresh, one of my treegrid column become hidden (event coded in
controller)
Answer:
We can achieve this by using hideColumn method in toolbarclick client side event. We have achieved this using client side event.
Please find the code snippet below:
|
<script type="text/javascript">
function toolbarClick(args) {
if (args.itemName == "Reset") {
var treeObj = $("#TreeGridContainer").data("ejTreeGrid");
treeObj.hideColumn("Task Id"); //Passing the header text to hide the column
}
}
</script> |
Please find the sample below
Note: We have removed the “Bin” and “Obj” folder for some security reason. Hence its necessary to add respective file from the build installed location from your side to run the sample.
Query3: Is there any documentations on how to create components in controller ?
Answer: Please find help documentation link for grid control below
Regards,
Punniyamoorthi
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
KS Kalai Sirajeddine
- Feb 22, 2018 03:52 PM UTC
- Feb 23, 2018 02:01 PM UTC