TreeView in a Window Checked Values After Postback

3 posts, 1 answers
  1. Sean Mars
    Sean Mars avatar
    10 posts
    Member since:
    Jan 2007

    Posted 29 Jul 2013 Link to this post

    I am using "appendTo" to place the Window inside the form. I receive an array with checked values for "checkedNodes" from the TreeView after the postback in FormCollection, but their values are "undefined". The values seem to be binding fine on the client side since I can check that there with no problem.

    @* ++++++ View ++++++ *@
    @using (Html.BeginForm(null, null, FormMethod.Post, new { name = "frmFind", id = "frmFind" }))
    {

    @Html.LabelFor(m => m.Things)
    @(Html.Kendo().Window()
        .Name("windowThings")
        .Title("Things")
        .Draggable()    
        .Actions(actions => actions
            .Minimize()
            .Maximize()
            .Close()
        ).Visible(false)
        .Resizable().Scrollable(true).Height(350)
        .Content(@<text>
                      @(Html.Kendo().TreeView()
                            .Name("treeThings")
                            .Checkboxes(checkboxes => checkboxes
                                                        .CheckChildren(true)
                            )
                            .DataTextField("Value")
                            )
                  </text>)
     )
    <span id="buttonOpenThings" class="k-button">Select Things</span>
    <script type="text/javascript">
        $("#windowThings").kendoWindow({
            appendTo: "#frmFind"
        });
    </script>
    }

    // ++++++ Controller ++++++
            [HttpPost]
            public ActionResult Index(FormCollection values) 
            {
                var checkedNodes = values["checkedNodes"]; // result is "undefined, undefined, undefined, [etc]"
                return View();
            }
  2. Sean Mars
    Sean Mars avatar
    10 posts
    Member since:
    Jan 2007

    Posted 29 Jul 2013 Link to this post

    Figured this out. I just needed to inform the HierarchicalDataSource of the schema. 

                    schema: {
                        model: {
                            id: "Id",
                            value: "Value"
                        }
                    }
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Answer
    Sean Mars
    Sean Mars avatar
    10 posts
    Member since:
    Jan 2007

    Posted 29 Jul 2013 Link to this post

    I figured this out. I just needed to inform the HierarchicalDataSource of the schema.  schema: { model: { id: "Id",  value: "Value" }   }
Back to Top