Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

  • Cell format value for field type 'icon'

    Hi,
    I have a simple list grid with following fields

    Code:
    data: myPersonalData
    fields : [{name : "companyId", title : "Title", width:"20%",showIf:"false"},
            {name : "modelName", title : "Name", width:"70%"},
            {name : "modelIcon", title : "Model Icon", width:"10%", type: "icon", cellIcon: "[SKIN]/actions/edit.png"  }
    ]
    myPersonalData looks like this
    [
    Code:
    myPersonalData : [
       {companyId: "tesla",
          modelName: "s3"}, /*  valid tesla model. So modelIcon should appear */
       {companyId: "tesla",
          modelName: "v3"}, /*  invalid tesla model. So modelIcon should display nothing */
    ]
    when an invalid modelName is given, modelIcon field should be hidden. (because in my case tesla doesnt have any model called v3) formatCellValue on field updateIcon doesnt work because it does not have a data source value to begin with.

    So how can one change the icon shown in modelIcon based on a value of field?

  • #2
    We're going to guess that you're talking about a ListGrid, and guess that you don't actually mean that the field should be hidden, but rather than you want the cell to be blank.

    If you use formatCellValue to render your icon you can simply check record.modelName to see if it's valid, then either write out an icon or not.

    Comment


    • #3
      Your assumptions are correct. Im using ListGrid. Im using SCImgURL to display icons as you can see in sample code I provided. Your suggestions makes a lot of sense.
      then either write out an icon or not
      How exactly can I do that? How can I create an instance of SCImgURL to be returned from formatCellValue?

      Comment


      • #4
        Since the default behavior of an icon field is to write out the icon, you can just return " " when you don't want an icon, or return this.getDefaultFormattedValue() when you do want the icon.

        Comment


        • #5
          Code:
          getDefaultFormattedValue
          did it! Thank you.

          Comment

          Working...
          X