1. #1
    Ext User
    Join Date
    Mar 2007
    Posts
    146
    Vote Rating
    0
    rahulmca1@gmail.com is on a distinguished road

      0  

    Default Populating Array Grid with one column hidden

    Populating Array Grid with one column hidden


    Hi,

    I am using Array Grid and populating grid form an array. But I wanted to know

    1. Can I Populate grid with columns id, name,salary using Array Grid so that in the grid id column remains hidden and is represents the row id of grid
    with array

    Code:
        var myData = [
    			[1,'John',5000],
                            [2,'Petric',8000]
                            ]
    just like what we do in dase of ajax xml grid using
    Code:
        var schema = {
                tagName: 'Item',
                id: 'ASIN',
                fields: ['Author', 'Title', 'Manufacturer', 'ProductGroup']
            };
    Can I use arrays in this case to populate grid.

  2. #2
    Ext Premium Member
    Join Date
    Mar 2007
    Location
    Norway
    Posts
    196
    Vote Rating
    3
    bone is on a distinguished road

      0  

    Default


    http://www.yui-ext.com/deploy/yui-ex...html#setHidden



    Code:
    myDataModel = new YAHOO.ext.grid.DefaultDataModel([
          [1,'john',5009],
          [2,'peter',8000]]);
    
    var cols = [
            {header: "Id"},
            {header: "Name"},
            {header: "Salary"}];
    
    myColModel = new YAHOO.ext.grid.DefaultColumnModel(cols);
    myColModel.setHidden(0);
    myGrid = new YAHOO.ext.grid.Grid('div-of-my-grid', myDataModel, myColModel);
    At least I think this is what you're looking for

  3. #3
    Ext User
    Join Date
    Mar 2007
    Posts
    146
    Vote Rating
    0
    rahulmca1@gmail.com is on a distinguished road

      0  

    Default


    Hi,

    Thanks for replying.

    I tried to use
    Code:
    myColModel.setHidden(0);
    to hide my column but it did not worked but when I tried

    Code:
    myColModel.setHidden(0,true);
    It works fine where as in documentation we do not have any such method
    docs say
    Code:
    public function setHidden(Number colIndex)
    Sets if a column is hidden.
    Thanks

  4. #4
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    You can specify hidden in your columnModel
    Code:
    {header:id, hidden:true}

  5. #5
    Ext Premium Member
    Join Date
    Mar 2007
    Location
    Norway
    Posts
    196
    Vote Rating
    3
    bone is on a distinguished road

      0  

    Default


    actually im using setHidden(0,true) myself, and it was used in my original reply in this thread. but i went back a couple of hours later and changed it to setHidden(0) because thats what it says in the docs (i didnt want to spread faulty code blabla)

    this is from DefaultColumnModel.js:
    Code:
        /**
         * Sets if a column is hidden.
         * @param {Number} colIndex The column index
         */
        setHidden : function(colIndex, hidden){
            this.config[colIndex].hidden = hidden;
            this.totalWidth = null;
            this.fireHiddenChange(colIndex, hidden);
        },
    once again we prove that code > docs

  6. #6
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    I would say that you were right to begin with. The docs are wrong. The correct usage is
    setHidden(0, true) or setHidden(0, false) to hide or show the column. However, note that calling this method fires the hiddenchange event. You may or may not have this event hooked, but if you do, it may not be correct to fire it when you are initially building the columnModel.

    If you're making a column hidden initially, e.g. when you're creating the CM, the way to do it is in the config with
    Code:
    {header:id, hidden:true}
    This way you don't fire an event that may have unintended consequences.

Similar Threads

  1. Array-grid example, maximum column allow is 21?
    By eric_sato in forum Ext 1.x: Bugs
    Replies: 1
    Last Post: 28 Mar 2007, 8:19 PM
  2. Hidden Column Headers
    By willpage in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 16 Jan 2007, 3:05 PM
  3. Problem with hidden column in grid
    By manugoel2003 in forum Ext 1.x: Bugs
    Replies: 7
    Last Post: 21 Dec 2006, 8:50 AM
  4. Replies: 2
    Last Post: 20 Dec 2006, 6:48 PM
  5. EditGrid hidden column
    By anakreon in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 25 Oct 2006, 2:05 AM

Thread Participants: 2