Telerik Forums
UI for ASP.NET MVC Forum
3 answers
235 views

Hi,

I have a requirement to have a TreeList which has up to 4 levels. I have the filter option enabled which gives me a filter to say Contains '' for example. When the first loads it loads with all nodes closed. When I apply the filter it only filters on what is shown directly in the view, so in this case on the top level items. Is there a way that it can filter on any child node as well, such that if a level 4 child node contained '' for example it would show the item expanded with the various parent nodes?

I can set it so that the view is always expanded, but then each time the view is rebound any user alterations to the expanded state are  by the expansion. 

Thanks,

Neil

Stefan
Telerik team
 answered on 10 Aug 2017
2 answers
235 views

I have a treelist bound to server data that i need to open to the same branch after refresh.

The refresh is done with a separate button that reloads the data from the database, and returns the path to the last selected tree node as list of the node's id's. Problem is that the tree is set to load data only when needed, so the loop this function runs attempting to expand the tree works too fast, and tries to expand nodes that the tree hasn't loaded yet.

Function code is following

function onRefreshClick() {
            var treelist = $("#treelist").data("kendoTreeList");
 
            treelist.dataSource.read();
             
           $.ajax({
                type: "POST",
                url: '@Url.Action("GetTreePath", "Tree")',
                data: { itemID: currentID },
                success: function (data) {
                    var dataArray = $.map(data, function (el) { return el });
 
                    for (i = 0; i < dataArray.length; i++) {
                        var rows = treelist.content.find("tr:visible");
                        var found = false;
                        for (var iRow = 0; iRow < rows.length; iRow++) {
                            if (found) {
                                break;
                            }
                            row = rows[iRow];
                            var cellI = 0;
                            if (row != undefined) {
                                while (row.cells[cellI] != undefined) {
                                    if (row.cells[cellI].innerText == dataArray[i]) {
 
                                        treelist.expand(row);
 
                                        alert("Opening tree");
 
                                        found = true;
                                        break;
                                    }
 
                                    cellI++;
                                }
                            }
                        }
                         
                    }
                }
            });
        }

The above works if the user dismisses the "opening tree" alert after the tree has loaded and opened the tree branch, but is it possible to make the function wait for the data to be loaded without manual control, or is there some other way to perform this function?

Keijo
Top achievements
Rank 1
 answered on 20 Jun 2017
1 answer
69 views

I am seeking help to understand the documentation found here:

http://demos.telerik.com/aspnet-mvc/treelist/remote-data-binding

My questions are:

In the following snip it 

public JsonResult Create([DataSourceRequest] DataSourceRequest request, EmployeeDirectoryModel employee)

{

if (ModelState.IsValid)

{

employeeDirectory.Insert(employee, ModelState);

}

return Json(new[] { employee }.ToTreeDataSourceResult(request, ModelState));

}

In this example the purpose is to create (insert) a new record. To do this this function calls the Insert method of the employeeDirectory method (which is presumable a method of the EmployeeDirectoryModel and it takes two parameters the employee (which was passed into this calling function, and the ModelState.

My question is, what does this Insert method do with the ModelState? It is passed in for a reason, so what is that reason?

The employee parameter will contain the data to be written to the database, except the primary key, does the Insert method load the primary key value into the model so that when it gets returned back (last line of snip it), there will be a fully loaded employee object?

When, where, how, does the ModelState get updated so that it knows that the employee object is full validated (i.e. has a primary key)?

Thank you

Alex Hajigeorgieva
Telerik team
 answered on 08 May 2017
3 answers
1.7K+ views

How do I apply custom HtrmlAttributes to custom tookbar or command buttons in a TreeList (using the MVC wrapper) ?

 

on Kendo Grids, we have used this extensively to set styling and tooltips, e.g. 

.ToolBar(toolbar => { toolbar.Custom().Text("").HtmlAttributes(new { id = "btnClearFilters", @class = "pm-btnFilterClear", title = "Clear all filters" }); })

However, there appears to be no equivalent HtmlAttributes methods on the TreeList toolbar or custom command buttons. 

 

Thanks.

 

Stefan
Telerik team
 answered on 03 May 2017
1 answer
59 views

Hello,

I have a radtreelist and I would like to extend a node according to the objects.

this is the .ascx side code :

<telerik:RadTreeList ID="WindowDynamicGrid" runat="server" AllowPaging="false" RenderMode="Lightweight"
    Skin="Metro" DataKeyNames="NodeId" ParentDataKeyNames="ParentId" ClientDataKeyNames="Value" Width="800px"
    AllowSorting="false" AllowFilteringByColumn="false" GridLines="None" OnNeedDataSource="WindowGrid_NeedDataSource"
    AutoGenerateColumns="false" AllowMultiRowSelection="false" ExpandCollapseMode="Client">
    <Columns>
        <telerik:TreeListSelectColumn HeaderStyle-Width="20" visible="true" /> 
    </Columns>
    <ClientSettings>
        <ClientEvents OnTreeListCreated="OnTreeListCreated" />
        <Selecting AllowItemSelection="true" />
        <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="true" />
    </ClientSettings>
</telerik:RadTreeList>

And this is the .ascx.cs side code :

protected void Page_PreRender(object sender, EventArgs e)
 {
        var expandedOrSelectedItems = controlItems.Cast<HierarchicalComboBoxItem>().Where(i => i.Checked || i.Expanded);
        foreach (var expandedOrSelectedItem in expandedOrSelectedItems)
        {
            var item = WindowDynamicGrid.FindItemByKeyValue("NodeId", expandedOrSelectedItem.NodeId);
            if (item != null)
            {
                item.Expanded = expandedOrSelectedItem.Expanded;
                item.Selected = expandedOrSelectedItem.Checked;
            }
       }
}

Do you have an idea of my problem ?

Thank you

I have a radtreelist and I would like to extend a node according to my objects to the pre_render
Marin Bratanov
Telerik team
 answered on 24 Apr 2017
3 answers
1.4K+ views

Hi,

I cannot get Click event on button inside <script type="text/x-kendo-template"> .

My code:

    <script type="text/x-kendo-template" id="template-sub">
        <div id="details-container-sub"  class="details-container">
            <table id="datails-sub-table" class="datails-table">
                <tr >
                    <th>Parameter</th>
                    <th>Value</th>
                </tr>
                <tr>
                    <td align="right">Connected By:</td>
                    <td>#= ConnectedBy #</td>
                </tr>
                <tr>
                    <td align="right">Connected On: </td>
                    <td>#= ConnectedOn #</td>
                </tr>
            </table>
            <div>
                <button id="btnClose" class="k-button close-button">Close</button>
            </div>
       </div>
    </script>

    @(Html.Kendo().Window().Name("Details")
        .Visible(false)
        .Modal(true)
        .Draggable(true)
        .Width(450)
    )

<script>

    function showDetails(e) {
        e.preventDefault();
        var wnd = $("#Details").data("kendoWindow");
        var treeItem = $("#ddlSubs").data("kendoTreeList").dataItem($(e.currentTarget).closest("tr"));
        switch (treeItem.Type) {
            case "sub":
                wnd.title("Subscription Details");
                wnd.content(kendo.template($("#template-sub").html())(treeItem));
                wnd.center().open();

               break;

             [.... more cases...]

        }

    }

    $(document).ready(function () {
       $('#Details').data("kendoWindow").bind('refresh', function (e) {
            var wnd = $("#Details").data("kendoWindow");
            $('#btnClose').click(function () {
                wnd.close();
            });
        });

    });

</script>

What is wrong?

Thank you in advance.

Boyan Dimitrov
Telerik team
 answered on 12 Apr 2017
18 answers
423 views

Hi,

 

Trying to create a TreeList view, but the data set is too large. exceed maxJson limit.  

So I'd like to load on demand.  Bring back the 1st level where the parentId string is null and then as each node is cliked have it return the next set of data.  I've a similar thread where the suggestion was to look at the emploeedirectory example, but don't see how that works per say. 

While trouble-shooting have noticed that trying to restrict the intial data request to just the top items where parentId is null does not work.  Tried to set default value for parentId as well but still does not work - "No Records to display"

However, changing the default parentId to a value and retricting the data query to that same value does return the items where their parent is the specified default value. 

I'm assuming there would be an inital query that brings back the top level items, but how would it show if there are sub items to select?  

Secondly, when a node is clicked would there need to be a clicked event that calls the controller to update the TreeList?  

Here is the controller method:

public ActionResult GetBoms([DataSourceRequest] DataSourceRequest request)
        {
            var db = new EmsDashDev();
            var results = db.NHAItems.ToList<NHAItems>();
            var results1 = results.ToTreeDataSourceResult(request,
                e => e.ComponentNumber,
                e => e.NextHigherAssembly);
            return Json(results1);
        }

And the view code

@(Html.Kendo().TreeList<EMSCommitScheduleApp.Models.NHAItems>()
    .Name("treelist")
    .AutoBind(true)
    
    .Columns(columns =>
    {
        columns.Add().Field(e => e.ComponentNumber).Width(280);
        columns.Add().Field(e => e.ItemNumber).Width(160);
        columns.Add().Field(e => e.Description);
        columns.Add().Field(e => e.Qty).Width(80);
        columns.Add().Field(e => e.NextHigherAssembly).Width(280);
        columns.Add().Field(e => e.LevelZeroAssembly);
        columns.Add().Field(e => e.AssemblyIndicator).Title("Make");
    })
    .Filterable()
    .Sortable()
    .DataSource(dataSource => dataSource
        .Read(read => read.Action("GetBoms", "Home"))
        .ServerOperation(true)
        .Model(m => {
            m.Id(f => f.ComponentNumber);
            m.ParentId(f => f.NextHigherAssembly);
            m.Expanded(false);
            m.Field(f => f.ComponentNumber);
            m.Field(f => f.ItemNumber);
            m.Field(f => f.Description);
            m.Field(f => f.Qty);
            m.Field(f => f.NextHigherAssembly);
            m.Field(f => f.LevelZeroAssembly);
            m.Field(f => f.AssemblyIndicator);
        })
        
    )
    .Height(540)
)

binta
Top achievements
Rank 1
 answered on 04 Apr 2017
3 answers
461 views

Hi,

Is it possible to have custom command button in TreeList?

I have tried to configure custom command button in Html.Kendo().TreeList as following:

                        @(Html.Kendo().TreeList<ABM.Models.AzureTreeViewData>()
                                .Name("ddlSubs")
                                .Columns(columns =>
                                {
                                    columns.Add().Field(e => e.Name).Width(480).TemplateId("node-template");
                                    columns.Add().Field(e => e.Type).Hidden(true);
                                    columns.Add().Field(e => e.SubID).Hidden(true);
                                    columns.Add().Command(command =>
                                    {
                                        command.Custom().Text(" ").Name("buttonCustom").Click("showDetails").ImageClass("fa fa-eye fa-lg");
                                    });
                                })
                                .Filterable()
                                .Sortable()
                                .Selectable(true)
                                .DataSource(dataSource => dataSource
                                    .Read(read => read.Action("TreeData", "Main").Data("subsdata"))
                                    .ServerOperation(true)
                                    .Model(m =>
                                    {
                                        m.Id(f => f.Id);
                                        m.ParentId(f => f.ParentId);
                                        m.Expanded(true);
                                        m.Field(f => f.Name);
                                        m.Field(f => f.Icon);
                                        m.Field(f => f.Type);
                                        m.Field(f => f.SubID);
                                    })
                                )
                        .Height(540)
                        )
<script>
    function showDetails(e) {
        e.preventDefault();

        var dataItem = $("#ddlSubs").dataItem($(e.currentTarget).closest("tr"));
 
        var wnd = $("#Details").data("kendoWindow");

        wnd.content(detailsTemplate(dataItem));
        wnd.center().open();
    }
</script>

Unfortunately Click event never hit in my code.

Could you please help me.

Thank you.

 

 

 

Tsvetina
Telerik team
 answered on 30 Mar 2017
1 answer
126 views

How can i apply an TemplateName or TemplateId to the Edit-Popup-Window of an TreeList?
I've got a partial-view named: MotivTreeViewViewModelEdit and i i want to set it to the Popup Window like in ASP.NET MVC Grid

....Editable(editable => editable.Mode("popup").TemplateName("MotivTreeViewViewModelEdit"))

The HtmlHelper supports the feature but i think it is not renderd.

Kind regards!

Konstantin Dikov
Telerik team
 answered on 14 Dec 2016
1 answer
270 views

Hi, i've a treelist with custom command, 

and i'm trying to change the button template with the databound event like the Grid

the visual result it's ok, but the event click doesn't fire, probably because i remove the k-button class.

but if leave the class the button doesn't template.

columns.Add().Command(command =>
                 {
                     command.Custom().ClassName("k-grid-EditCustom").Text(" ").Name("EditCustom").Click("editGroup");
                     command.Custom().ClassName("k-grid-DeleteCustom").Text(" ").Name("DeleteCustom").Click("deleteGroup");
 
                 }).Width(150);
 
function treeGridGroup_DataBound(e) {
     e.sender.tbody.find(".k-grid-EditCustom").removeClass("k-button")
     e.sender.tbody.find(".k-grid-EditCustom").addClass("btn btn-warning btn-outline fa fa-pencil");
 
     e.sender.tbody.find(".k-grid-DeleteCustom").removeClass("k-button")
     e.sender.tbody.find(".k-grid-DeleteCustom").addClass("btn btn-danger btn-outline fa fa-trash-o m-l-5");
 }
Kostadin
Telerik team
 answered on 05 Dec 2016
Narrow your results
Selected tags
Tags
+? more
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?