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

[Solved] Load On Demand - Hierarchical Data, multiple data sources

0 Answers 26 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jason
Top achievements
Rank 1
Jason asked on 11 Sep 2012, 05:55 PM
Hi,
I'm using the treeview, highly customized and am trying to get set the databound event on the child node.  You'll understand better after seeing my code.

// in my partial view
 
@(Html.Telerik().TreeView()       
    .Name("OperationBrowserTree")
    .ClientEvents( events => events
                .OnSelect( "OperationBrowserTree_click" ) )
    .BindTo(Model, (item, operation) =>      
    {
         
        // bind initial data - can be omitted if there is none           
            item.Text = string.Format( HTML BLOCK HERE );
        item.Value = 'O' + operation.ID.ToString();        
        item.LoadOnDemand = operation.Steps.Count() > 0;
        item.Encoded = false;      
        })
          
    .DataBinding(dataBinding => dataBinding
        .Ajax().Enabled( true ).Select( "GetOperationBrowserSteps" , "ShopFloor" )
        )
    )
// in my controller
public ActionResult GetOperationBrowserSteps( TreeViewItem node )
        {
            int operationID = Convert.ToInt32( node.Value.Substring(1) );
             
            using( var ctx = ErpContextFactory.Create() )
            {
                var steps = ctx.Steps
                    .IncludeRelation( "TestPlanResults/TestPlan" )
                    .Where( st => st.OperationID == operationID ).OrderBy( st => st.StepNumber ).ToArray().Select(
                    st => new TreeViewItemModel
                    {
                        Text = string.Format( HTML BLOCK HERE),
 
                        Value = "S" + st.ID.ToString(),
                        Enabled = true,
                        Encoded = false,
                        LoadOnDemand = st.TestPlanResults.Count > 0
                    }
                    ).ToArray();
                return new JsonResult { Data = steps };
            }
        }

this works great and gives me a tree with parent of operations and child of steps.  but now, i need to add a second child of tests on those steps.  Can I add something like :
.DataBinding(dataBinding => dataBinding
        .Ajax().Enabled( true ).Select( "GetOperationBrowserSteps" , "ShopFloor" )
        )

to the TreeViewItemModel in the controller, where I can call a second controller method?

Thanks! Jason
Tags
TreeView
Asked by
Jason
Top achievements
Rank 1
Share this question
or