Announcement

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

    ListGrid.hideFields

    I want to dynamically show/hide fields when data has arrived. I have the following code, but when I click on the button that is supposed to hide Country Name, it doesn't do anything.

    Code:
    isc.ListGrid.create({
        ID: "countryList",
        width:500, height:224, alternateRecordStyles:true,
        data: countryData,
        fields:[
            {name:"countryCode", title:"Flag", width:50, type:"image", imageURLPrefix:"flags/16/", imageURLSuffix:".png"},
            {name:"countryName", title:"Country"},
            {name:"capital", title:"Capital", showIf:"false"},
            {name:"continent", title:"Continent"}
        ],
        canReorderFields: true
    })
    
    
    isc.IButton.create({
        left:0, top:240,autoFit: true,
        title:"Hide Country Name",
        click:function(){
              var arr = new Array();
              arr[0] = this.getField('countryName');
              countryList.hideFields(arr);
              countryList.refreshFields();
        }
    })

    #2
    Get rid of the call to refreshFields(), it's not necessary and is effectively undoing your call to hideFields().

    Comment


      #3
      I only added that because hideFields() was not doing anything..

      Code:
      
      isc.IButton.create({
          left:0, top:240,autoFit: true,
          title:"Hide Country Name",
          click:function(){
                var arr = new Array();
                arr[0] = this.getField('countryName');
                countryList.hideFields(arr);
          }
      })

      Comment


        #4
        Uh wait a minute - you are calling this.getField() on a Button.

        Comment


          #5
          "duh" is the word..thanks :)

          Comment


            #6
            I want to take my case further and hide particular fields when dataArrived is called - unless you can suggest another way of doing it - I want to hide a column based on data I receive from the fetch request.

            Code:
            
            isc.ListGrid.create({
                ID: "countryList",
                data: countryData,
                fields:[
                    {name:"countryCode", title:"Flag", width:50, type:"image", imageURLPrefix:"flags/16/", imageURLSuffix:".png"},
                    {name:"countryName", title:"Country"},
                    {name:"capital", title:"Capital", showIf:"false"},
                    {name:"continent", title:"Continent"},
                    {name:"test", title:"test"}
                ],
                    dataArrived: function(){
                       var arr = new Array();
                        arr[0] = this.getField('countryName');
                      this.hideFields(arr);
                 },
                canReorderFields: true
            })

            Comment


              #7
              That's a reasonable approach. The alternative would be to delay creation of the ListGrid until you've fetched the data.

              Comment


                #8
                I forgot to mention that putting the code in dataArrived doesn't work. The column is still there.

                Comment


                  #9
                  That's probably because dataArrived does not fire since your code doesn't fetch at all. Could you check on some of these basic possibilities on your own? We're trying to fix your tabbing issue.

                  Comment

                  Working...
                  X