0

Creating a dojo treegrid using the example from Brad Balassatis: "Create a Categorized Dojo TreeGrid in XPages"

The grid is created, but how do have a onClick event on the row or grid?

i try to use the below function but i get error :Uncaught ReferenceError: item is not defined

var grid = new dojox.grid.TreeGrid({
    treeModel: treeModel,
    structure: layout,
    showRoot: true,
    onClick:  test(item, node, evt)

}, 'treeGrid');

function test (item, node, evt){    
    var id=jsonStore.getValue(dijit.getEnclosingWidget(node).item, docId);
    alert("Execute of node " + id)

}
simon peter
  • 403
  • 8
  • 19

1 Answers1

0

In the param onClick you are executing the test function. You have to put just a reference to the function there:

var grid = new dojox.grid.TreeGrid({
    treeModel: treeModel,
    structure: layout,
    showRoot: true,
    onClick:  test

}, 'treeGrid');

Or, use an anonymous function:

var grid = new dojox.grid.TreeGrid({
        treeModel: treeModel,
        structure: layout,
        showRoot: true,
        onClick:  function (item, node, evt) {    
               var id = jsonStore.getValue(dijit.getEnclosingWidget(node).item, docId);
               alert("Execute of node " + id);
           }    
    }, 'treeGrid');
Txemanu
  • 449
  • 2
  • 7
  • i try that and got the error Uncaught "TypeError: Cannot read property 'item' of null" – simon peter Aug 27 '15 at 08:32
  • have you checked the params you receive in the onClick function of a dojox.grid? You should check in the API how to use this event. Be sure you check the dojo version you are using. Here you have similar question: http://stackoverflow.com/questions/4396064/dojox-grid-datagrid-how-to-access-data-from-a-click-event – Txemanu Aug 31 '15 at 08:45