1

On Page 1 I get the object I need:

ProjectSearchCriteria = (GBLProjectSearchCriteria)Session[GblConstants.SESSION_PROJECT_SEARCH_CRITERIA];

I'm trying to pass this to an API on a page load of Page 2.

Page 2:

<!DOCTYPE HTML>
<html>
    <head>
        <title></title>
        <link href="../x.css" type="text/css" rel="stylesheet">
        <link href="../Content/kendo.common.min.css" rel="stylesheet" />
        <link href="../Content/kendo.default.min.css" rel="stylesheet" />
    </head>
    <body>
        <form id="frmProjectSearchResults" runat="server">
        </form>
        <script src="../Scripts/ProjectsTreeView.js"> </script>
        <script type="text/javascript">
            CreateProjectTree(<%= ProjectSearchCriteria %>);
        </script>
    </body>
</html>

And this is the JavaScript function:

function CreateProjectTree(searchCriteria)
{
    debugger;
    var projects = new kendo.data.HierarchicalDataSource({
        transport: {
            read: {
                url: "../api/projects?searchcriteria =" + searchCriteria,
                contentType: "application/json"
            },
            parameterMap: function (data, operation) {
                return JSON.stringify(data);
            }
        },
        schema: {
            model: {
                children: "seasons"
            }
        }
    });

    $("#treeview").kendoTreeView({
        dataSource: projects,
        loadOnDemand: true,
        dataUrlField: "LinksTo",
        checkboxes: {
            checkChildren: true
        },
        dataTextField: ["Title"],
        select: treeviewSelect
    });

    function treeviewSelect(e) {
        var node = this.dataItem(e.node);
        window.open(node.NotificationLink, "_self");
    }
}

Can anyone help me understand what I'm doing wrong?

1
  • Is your browser throwing any javascript error? Why is this not working for you? Commented Aug 12, 2013 at 17:39

1 Answer 1

1

Maybe this:

<script type="text/javascript">
    CreateProjectTree("\"" + <%= ProjectSearchCriteria %> + "\"");
</script>
Sign up to request clarification or add additional context in comments.

3 Comments

+1 - this is almost as good advice as it can get for the question, maybe some JSON-ification of ProjectSearchCriteria would be nice, but not possible in generic case based on information provided. @Rj - you need to look at resulting HTML and see what is actually generated and if it matches you expectations.
after I added what Alesandro said, now I get ""NaN" as the value of the object (in the java script function)
what is the value of "ProjectSearchCriteria"?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.