0
votes

I created a separate class in .js file to create grid for me,my class is simple as following:

function createDynamicGrid(chartId, source, column, titleOfGrid,onChange) {
    chartId.kendoGrid({
    toolbar: titleOfGrid,
    dataSource: {
        data: source,
    },
    change: onChange,
    height: 350,
    scrollable: true,
    sortable: true,
    filterable: true,
    columns: column,
    noRecords: {
        template: "No data"
    },
    });
    }

in my view(.Cshtml) when i call this and pass parameters i get the chart but click event does not trigger,here in cshtml:

createDynamicGrid(chartId, source, column, titleOfGrid,onChange);

  function Change(e){

    //i want to get e result here,but i cant

        }
1
Please post a fiddle or equivalent replicating your problem. (And this is not a class. This is a function.) - Marco

1 Answers

0
votes

First, you're defining your Change function after the grid creation, which is where you need the function's reference. It should be defined before the grid creation;

Second, the way you did, you need to pass the function as a parameter, and you're not doing it.

Try this:

createDynamicGrid(chartId, source, column, titleOfGrid, function(e)
{
    // This is your change event
});

Or the equivalent:

lar changeEvent = function changeEvent(e){
    //i want to get e result here,but i cant
}

createDynamicGrid(chartId, source, column, titleOfGrid, changeEvent);