• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

[SOLVED] Interpreting ExtJS API Docs?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [SOLVED] Interpreting ExtJS API Docs?

    If the Ext docs for a config property states (for example):

    icon : String
    The URL of an image to display as the clickable element in the column.
    Defaults to Ext.BLANK_IMAGE_URL.


    does this mean it has to be a hard coded string?
    Or can it be a variable that contains a string or even a variable that is a function that returns a string?

    for example:
    icon: myFunction()

    where my function is defined elsewhere as

    var myFunction = function(){
    if(rec.get('NOTES') === 'Y'){
    return '<img src="/icons/note.png">';
    }
    }

  • #2
    Back in grade school the correct answer would be "There's not enough information here for an answer." But let's get thinking or get some more info:

    This icon function will run at the instantiation of your object which has an icon.

    So what is rec.get('NOTES') at this point? Or for that matter rec?

    Where are you showing this icon? Do you expect it to change consistently based on the value of rec.get('NOTES') or just when it is rendered?

    Comment


    • #3
      Maybe I over thought it....The answers to your questions were No and Yes.

      Comment


      • #4
        Well, to give you more background, I have an app where I am creating a grid and a store dynamically. When the view is instantiated, the columns are empty columns: [{}] and the store for the grid has no fields. fields: []

        I build both using data I get from JSON and do a mymodel.model.setFields(fields) and grid.reconfigure(store, columns). pretty neat.

        I'm trying to add a column to hold icons indicative of certain flags in the record. So based on other columns I am going to do a column.push(). As I was playing around with it, turns out I can use:

        renderer: function(meta, v, rec){
        if(rec.get('NOTES') === 'Y'){
        return '<img src="/images/note.png">';
        }
        }

        Whala!

        Comment

        Working...
        X