3.2.0

hyperlink and javascript in a cell

I like the ActiveWidgets. It is a very nice tool and I am investigating whether to buy it or not. Therefore I am analyzing the possibilities of this widget.

A critical decision point is whether I am able to create an image per cell and depending on a javascript confirmation I can go to a url. It is easier to describe using an example:

The widget contains a list of users. In the last column(s) there are a few options, like edit and delete (both with an image). When I click the delete-image, i want javascript confirmation (Are you sure you want to delete this user?) and - if confirmed - an url, like users.php?function=delete&userId=55.

I am able to get the images in the cells that i want, but i am unable to deal with the links/javascript.

I got it working in Firefox, but not in Internet Explorer. Any help?
obj.setCellModel(table);
    obj.setCellTemplate(new AW.Templates.ImageText);
    obj.setCellImage("deleteImage", 7);
    obj.setCellLink("javascript:void(7);", 7); 
    obj.setCellTemplate(new AW.Templates.Link, 7);    // and template 
    obj.onCellClicked = function(event, col, row)
    {
        if (col==7)
        {
            if (confirm('Are u sure you want to delete '+ this.getCellText(3, row) + ' '+ this.getCellText(2, row) + ' from the system?'))
            {

                strLink = "users.php?function=testToDelete&userId="+this.getCellText(0, row);
                window.location.href=strLink;
            }
        }
    };  
    //	write grid html to the page
    document.write(obj);

Joshua Kroeze
July 11,
Problem solved: This is working both in IE and Firefox.

col 2 + 3 contains lastName,firstName
col 0 contains userId
col 7 contains delete-image
function confirmDelete(elem,link)
    {
        if(confirm('Are you sure you want to delete '+elem+' ?'))
        {
            window.location.href=link;
        }
    }

    //	assign external 'data model'
    obj.setCellModel(table);
    obj.setCellTemplate(new AW.Templates.Link, 6);
    obj.setCellTemplate(new AW.Templates.ImageText);
    obj.setCellImage("deleteImage", 7);
    
    obj.setCellLink(function(c, r){ return "javascript: confirmDelete('"+this.getCellText(3,r)+' '+this.getCellText(2,r)+"','user.php?function=delete&userId="+this.getCellText(0,r)+"')"; }, 7); 
    obj.setCellTemplate(new AW.Templates.Link, 7);    // and template
Joshua Kroeze
July 11,

This topic is archived.

See also:


Back to support forum