0

i have a onclick event inside my chart,whenever its clicked ,the function is invoked and find what is clicked,now,in my main page,i need to know when the function is invoked to get its value,how should i do that?

 function pieChartForInterventions(chartID,pieChartData) {

chartID.kendoChart({
    dataSource: {
        data: pieChartData
    },
    series: [{
        type: "pie",
        field: "list",
        categoryField: "mm",
        padding: 0,
        labels: {
            visible: true,
        }
    }],
    seriesClick:onDb,
    tooltip: {
        visible: true,
        template: "${ category }"
    }
    ,
    legend: {
        position: "bottom"
    }
});

 }

function onDb(e) {
 debugger;
 var _clicked = e.category;
 var whatClicked;
 debugger;
 return _clicked;

 }

onDb function get the value of chart when its clicked,now i want to have this value,how can i get the returned value of onDb() on my main page and save it?

var s=onDb() 

this does not work

  • Set up a page level variable and have the function set that variable. Or have the function call another function that sets the value. – Scott Marcus May 10 '18 at 13:18
  • @ScottMarcus i cant implement it really,im new in js,can you please help? –  May 10 '18 at 13:20
  • Scott is telling you to declare a variable outside of all of your functions (page-level variable). Then, inside of onDb(), set that variable's value. Now you can access that variable's value in any of your other functions. – Ryan C May 10 '18 at 13:22
  • @RyanC now i understood,but in my main page,how should i check if this variable has value or not?lets call it temp –  May 10 '18 at 13:27
  • Can you expand on your context please? Are you trying to have a function fire on when that variable changes? If so, it would be best to create another function that does the logic you need and call this new function inside your onDb function. – Ryan C May 10 '18 at 13:31
  • basically this onDb() invokes when i click on chart,so it saves the value for me in a variable,now in my main page,i need this value,here the problem is,how should i get this value out of this onDb(),upon a click –  May 10 '18 at 13:34
  • You say "main page", are these on different web pages? – Ryan C May 10 '18 at 13:36
  • @RyanC its my view in mvc asp.net application,and all these javascripts are in a seperate file,in my main view,i need to have the value of what i have clicked on this chart, –  May 10 '18 at 13:37
  • You should look at using cookies or local storage to store the value so you can access it on another page. https://stackoverflow.com/questions/2010892/storing-objects-in-html5-localstorage – Ryan C May 10 '18 at 13:38
  • @RyanC i created a page lever variable,and stored the value of onDB in it,now,how should i find if my page level variable has value?how should i create function to watch it always if its empty or not? –  May 10 '18 at 13:41

0 Answers0