Announcement

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

    Show/Hide a column while loading a listGrid based on a condition

    I want hide a column of a listgrid if a record column value doesn't meet a condition.

    Columns: A, B, C
    If C record value is not "1" for at least one of the last records loaded, I want hide the C column using this.hideField("C"). If at least one, I create a button in this column for the one with "1" value.

    Currently I have:
    Code:
    ...
    fields: [
    {name:"A"},
    {name:"B"},
    {name:"C", 
        formatCellValue:function (value) { return '';}
    },
    createRecordComponent : function (record, colNum){
        var cField = this.getFieldName("colNum");
        if(cField == "C"){
              var cFieldValue = record["cField"];
              if(cFieldValue=="1"){
                  var button=isc.IButton.create({...});
              }else{
                  return null;
              }
        }else{
              return null;
        }
    }
    I am surprised to see that there is no methods to allow to hide the column after the listGrid load like onLoadComplete or fetchComplete.
    I would have something like:

    Code:
    ...
    var hideCColumn = true;
    this.myListGrid = isc.ListGrid.create({
    ...
    fields: [
    {name:"A"},
    {name:"B"},
    {name:"C", 
        formatCellValue:function (value) { return '';}
    },
    createRecordComponent : function (record, colNum){
        var cField = this.getFieldName("colNum");
        if(cField == "C"){
              var cFieldValue = record["cField"];
              if(cFieldValue=="1"){
                  hideCColumn = false;
                  var button=isc.IButton.create({...});
              }else{
                  return null;
              }
        }else{
              return null;
        }
    },
    fetchComplete: function(){  //does not exist in isomorphic
        if(hideCColumn){
              this.hideField("C");
        }
    }

    Do you confirm I can not do that with smartclient?

    Thanks.
    Last edited by mickaelterrien; 18 Mar 2014, 08:59.

    #2
    SmartClient comes with searchable documentation, which it's very important to use.

    fetchData() has a callback that fires when the fetch is complete.

    dataArrived() fires whenever data arrives.

    Both are very easy to find, and linked from properties you are already using.

    Comment


      #3
      Thanks for your answer but it partially answers.

      I can see that the fetchData callback is run before I set the boolean in the createRecordComponent() function. So that means the hideFields() use has no incidence on the grid.

      Code:
      var hideCColumn = true;
      this.myListGrid = isc.ListGrid.create({
      ...
      autoFetchData: false;
      fields: [
      {name:"A"},
      {name:"B"},
      {name:"C", 
          formatCellValue:function (value) { return '';}
      },
      createRecordComponent : function (record, colNum){
          var cField = this.getFieldName("colNum");
          if(cField == "C"){
                var cFieldValue = record["cField"];
                if(cFieldValue=="1"){
                    hideCColumn = false;
                    var button=isc.IButton.create({...});
                }else{
                    return null;
                }
          }else{
                return null;
          }
      }
      );
      this.myListGrid.fetchData(null, function(){
          if(hideCColumn){
                this.myListGrid.hideField("C");
          }
      }
      I would like to hide this field and maybe that it is better to do that after the listgrid is loaded :

      Code:
      this.myListGrid.onLoadComplete(null, function(){
          if(hideCColumn){
                this.myListGrid.hideField("C");
          }
      }
      Is there a way to do this kind of thing with smartclient?

      Finally, my question is:
      Is there a way to hide a column with a condition that is testing the content of the column in the data fetched?


      Originally posted by Isomorphic View Post
      SmartClient comes with searchable documentation, which it's very important to use.

      fetchData() has a callback that fires when the fetch is complete.

      dataArrived() fires whenever data arrives.

      Both are very easy to find, and linked from properties you are already using.
      Last edited by mickaelterrien; 18 Mar 2014, 11:13.

      Comment


        #4
        Sorry, we don't follow what that sentence is supposed to mean.

        Please consider our commercial services if you need further assistance.

        Comment


          #5
          I would like to hide this field and maybe that it is better to do that after the listgrid is loaded :

          Code:
          this.myListGrid.onLoadComplete(null, function(){
              if(hideCColumn){
                    this.myListGrid.hideField("C");
              }
          }
          Is there a way to do this kind of thing with smartclient?

          Finally, my question is:
          Is there a way to hide a column with a condition that is testing the content of the column in the data fetched?

          Comment

          Working...
          X