Governator
Governator

Reputation: 11

gridx cellwidget scope - can't execute external javascript

I have been trying to create a cellwidget button within gridx that once clicked it will call a javascript function externally. so the set up is i have the file test.html which contains a gridx grid with the following field declared in html

{ field: 'action', 
    name:'action', 
    widgetsInCell: true,
    navigable: true,
    width :             '5%',
    class:'linkButton',
    decorator: function(){
        return '<button class=&quot;linkButton&quot; baseClass=&quot;linkButton&quot; data-dojo-type=&quot;dijit.form.Button&quot; iconClass=&quot;deleteButtonIcon&quot;></button>'
    },
    setCellValue: function(gridData, storeData, cellWidget){
    var status = cellWidget.cell.row.data()[3];
    var id = cellWidget.cell.row.id;

    if (status=='abc')
    {
    cellWidget.domNode.hidden=false;
        if(cellWidget.btn._cnnt){  
            cellWidget.btn._cnnt.remove();  
        }  
        cellWidget.btn._cnnt = dojo.connect(cellWidget.btn, 'onClick', function(e){  

            alert('test');
            deleteRecord('');

        });
       } 
    }}

The alert happens fine but the problem is that the deleteRecord function can not be found - this function is in a test.js file and is being loaded using the script tag

<script type="text/javascript" charset="utf-8" src="/test.js"></script>

i suppose my questions are

  1. am i do something wrong above?
  2. what is the scope of the cellwidget, can it call external js scripts?
  3. is there a way to connect the button to an event in the .js file (dynamically loaded so can't use id)?
  4. how is it done using attach points?

Upvotes: 1

Views: 68

Answers (0)

Related Questions