How to get a treepanel node selection to run an Ajax request

  1. #1

    How to get a treepanel node selection to run an Ajax request

    I have a chart that I can reuse for different kind of data. I created a treepanel from the Simple example in which I display selections that can determine how the chart is going to display the data. This is the setup:

    The chart has the following Proxy:
    .Proxy(
                                                                            Html.X().AjaxProxy()
                                                                                .Url(Url.Action("GetChartData", new { id = 1 }))
                                                                                .ActionMethods(actions =>
                                                                                {
                                                                                    actions.Read = HttpMethod.POST;
                                                                                })
                                                                                .Reader(
                                                                                    Html.X().JsonReader().Root("result")
                                                                                )
    The treepanel has the NodeID of each leaf setup to a number. So
    TreePanel
    ------ ITem 1 NodeID=1
    ------Item 2 NodeID = 2


    I want to select the item from tree and dynamically change the url of the chart and reload the chart with the new data. The problem that I am having is how to dynamically change the chart url from the tree selection. I would want something like:
    .Url(Url.Action("GetChartData", new { id = TreePanle.NodeID }))
    Last edited by Daniil; Oct 17, 2013 at 5:48 AM. Reason: Please use [CODE] tags
  2. #2

    Further information

    The chart's store ID is "Store2"

    I was wondering if there is something I can do in client script such as:

    <script>
          
           var treePanelItemclicked = function (item, record, node, index, e) {
                          App.Store2.setProxy({ url: '/Dashboard/GetChartData/' + record.data.id });
           };
        </script>
    I tried this looking at some of the examples from TreePanel but it does not work. Not sure about setProxy or some other way to change the url for the store proxy from script.
    Last edited by Daniil; Oct 17, 2013 at 5:49 AM. Reason: Please use [CODE] tags

Similar Threads

  1. Replies: 11
    Last Post: Feb 06, 2013, 5:09 PM
  2. [CLOSED] TreePanel: cancel node selection change event
    By coleg123 in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Nov 03, 2011, 6:47 AM
  3. Treepanel how to get selected node without using a Ajax event or method ?
    By lordofthexings in forum Examples and Extras
    Replies: 5
    Last Post: May 26, 2010, 12:02 PM
  4. Page_ Ajax Load Complete BUG on Ajax Request
    By jeybonnet in forum 1.x Help
    Replies: 8
    Last Post: Jun 22, 2009, 11:19 AM
  5. Replies: 0
    Last Post: May 27, 2009, 6:30 PM

Tags for this Thread

Posting Permissions