Announcement

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

    Add a column in smartclient list grid at run time

    Hello,

    I have created a list grid and want to add columns at run time by clicking on a button,means when i click on the button one column should be added, help me as I am new to smartclient.

    Thanks
    Sumit
    Last edited by sumit7nov; 25 Nov 2009, 07:02. Reason: spelling mistake

    #2
    Re: Add grid column on runtime

    As I faced this issue, I've reallized that if I declare that column in datasource with <showIf>false<showIf>. The column will not display any where. and Do the code

    tabPane.gridName.listGrid.showField('columnName to Show');

    This will display the column on runtime.

    Regards
    Crider

    Comment


      #3
      Thanks for the reply,but this will solve only partial problem as suppose we add 2 coulmns and put it in hiding status,but supoose i need to add 5 coulmns or more than that at run time then this solution will not work.

      Comment


        #4
        Same problem here. Is there a solution somewhere?

        Update: I found a solution. For further reference:

        I added this function to my ListGrid class. It adds an empty column with increasing number as name

        addColumn: function() {
        var fields = this.getFields();
        fields[fields.length] = {name:""+(fields.length+1), title:"", width:70};
        this.setFields(fields);
        }
        Last edited by gd@geneon.de; 8 Jun 2010, 04:32.

        Comment


          #5
          Code:
          var fields = listGrid.getAllFields() || [];
          fields.add({ name: "field1", title: "New field" });
          listGrid.setFields(fields);
          Last edited by marpetr; 8 Jun 2010, 03:52.

          Comment

          Working...
          X