Hybrid View

  1. #1
    Ext User
    Join Date
    Mar 2007
    Posts
    56
    Vote Rating
    0
    donalconlon is on a distinguished road

      0  

    Default Can a column display a graphic?

    Can a column display a graphic?


    Is it possible for acolumn to display a graphic? Either static, or based on the value in the cell?

  2. #2
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    16
    jack.slocum will become famous soon enough

      0  

    Default


    Yes, using a renderer function.

    Code:
    function renderImage(value, rowIndex, colIndex){
        return '[img]myimage.gif[/img]';
    }
    // then in your column model definition:
    var myColumns = [
    	{header: "Icon", width: 20, renderer: renderImage}, 
            ...
    ];
    Note: If you need to display big images you will have to customize the row/cell heights defined in the CSS.

  3. #3
    Ext User
    Join Date
    Mar 2007
    Posts
    123
    Vote Rating
    0
    techno_adi is on a distinguished road

      0  

    Default Re: Can a column display a graphic?

    Re: Can a column display a graphic?


    Can somebody explain the second part of the question "based on the value in the cell". How do i update only one row's image cell based on the value in other (assuming that the value is editable)?
    Quote Originally Posted by donalconlon
    Is it possible for acolumn to display a graphic? Either static, or based on the value in the cell?

  4. #4
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    16
    jack.slocum will become famous soon enough

      0  

    Default


    You will need a reference to your DataModel to get the other cell's value.

    Code:
    // create your data model
    var dataModel = {...}
    
    function renderImage(value, rowIndex, colIndex){
        if(value == 'foo'){
             return '[img]foo.gif[/img]';
        }else{
             // get the value at row 1, column 1
             var otherValue = dataModel.getValueAt(1, 1);
             if(otherValue == 'bar'){
                   return '[img]bar.gif[/img]';
             }else{
                  return '[img]none.gif[/img]';
             }
        }
    }

  5. #5
    Ext User
    Join Date
    Mar 2007
    Posts
    123
    Vote Rating
    0
    techno_adi is on a distinguished road

      0  

    Default


    Quote Originally Posted by jacksloc
    You will need a reference to your DataModel to get the other cell's value.

    Code:
    // create your data model
    var dataModel = {...}
    
    function renderImage(value, rowIndex, colIndex){
        if(value == 'foo'){
             return '[img]foo.gif[/img]';
        }else{
             // get the value at row 1, column 1
             var otherValue = dataModel.getValueAt(1, 1);
             if(otherValue == 'bar'){
                   return '[img]bar.gif[/img]';
             }else{
                  return '[img]none.gif[/img]';
             }
        }
    }
    i tried this out, it works great..
    But when i tried doing
    var otherValue = dataModel.getValueAt(rowIndex, 1);
    it flags an error as to
    this.data[rowIndex] is not a valid property ( for yui-ext.js file)

  6. #6
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    16
    jack.slocum will become famous soon enough

      0  

    Default


    The rowIndex, colIndex parameters appear to be additions in the new version. I thought they were present in the old version but they are not.

    The version will be out on Monday and has these parameters.

Similar Threads

  1. IE display problems
    By wilzmodz in forum Ext 1.x: Help & Discussion
    Replies: 4
    Last Post: 31 Mar 2007, 8:54 AM
  2. YAHOO.ext.Element Display
    By ojintoad in forum Ext 1.x: Help & Discussion
    Replies: 6
    Last Post: 1 Jan 2007, 2:20 AM
  3. Can i display a tab again after close it?
    By kirk in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 4 Dec 2006, 3:48 PM
  4. Cannot display 0 in grid
    By alcarx in forum Ext 1.x: Bugs
    Replies: 1
    Last Post: 16 Oct 2006, 2:54 AM

Thread Participants: 2