Hide gridcommand from a command column of a gridpanel

  1. #1

    Hide gridcommand from a command column of a gridpanel

    Hi

    In my code I have a gridpanel with edit, delete & other commands in every rows.
    I want to hide 2 command i.e. delete & other and want to change the tooltip text of edit command as show details.

    I want to hide command as per the role of user.
    If the role is admin than command should not hide else hide.

    How can I do this??????????


    Vaishali Khatri
    Kintu Designs PVT LTD.
  2. #2
    Hi vaishali

    To hide a column u have to write on server side

    gridpanel1.ColumnModel.SetHidden(7, True)
    :-7 is the indiex of the column and set true false to hide and show
    Last edited by Daniil; Feb 24, 2012 at 11:58 AM. Reason: Please use [CODE] tags
  3. #3
    and to change the tool tip

    u have to add
    <ToolTip Text="Show Details" />
    in side the command column
    Last edited by Daniil; Feb 24, 2012 at 11:57 AM. Reason: Please use [CODE] tags
  4. #4
    Hi hardik

    Actually code you have given is not working properly it hides all commands.
    I dont want that....
    I have already solved the problem using javascript
     var prepareToolbar = function (grid, toolbar, rowIndex, record) {
         
         
    
                    toolbar.items.itemAt(1).hide();
                 
                    toolbar.items.itemAt(2).hide();
                   
                
                
            };
    
    
    
    
    
     <ext:CommandColumn>
                        <Commands>
                            <ext:GridCommand  CommandName="Edit"  Icon="ApplicationEdit" >
                                <ToolTip Text="Edit"/>
                            </ext:GridCommand>
                            <ext:GridCommand CommandName="Delete"  Icon="Cross">
                                 <ToolTip Text="Delete"/>
                            </ext:GridCommand>  
                            <ext:GridCommand CommandName="ChangePassword" Icon="Key">
                                 <ToolTip Text="Change Password"/>
                            </ext:GridCommand>   
                                      
                        </Commands> 
                       
                         <PrepareToolbar Fn="prepareToolbar"/>
                    </ext:CommandColumn>
  5. #5
    ohh i thought you must be having different columns for each command
  6. #6
    But still there is a problem how can I check the role of a user where I write a condition?
    If I write

    If(('<%=Usergroup%>')=="User_roleWhatever")
    Inside below code the error occurs...
      var prepareToolbar = function (grid, toolbar, rowIndex, record) 
           {
                 
                 
                   toolbar.items.itemAt(1).hide();
                    toolbar.items.itemAt(2).hide();            
            };
  7. #7
    Hi vaishali
    No it will not work..Because prepare toolbar is an renderer function which is called on each row of the grid..like same as databound event in asp grid
    So what u can do is
    If u have any label or something on ur page Displaying user role,
    Then u can check that labels text inside the prepare toolbar
    or if u dnt have any such label then u have to use a hidden control and set the role permission in it and check the value of the hidden inside the prepare tool bar function

    Like

    var prepareToolbar = function (grid, toolbar, rowIndex, record) {
         
         
                  if(hidden1.getValue()=='Admin'){
                   toolbar.items.itemAt(1).hide();
                 
                   toolbar.items.itemAt(2).hide();
                   }else{
     toolbar.items.itemAt(1).show();
                 
                   toolbar.items.itemAt(2).show();
    }
                
                
           };
    the same above code goes for label
  8. #8
    Hi hardik,

    how to solve it for different columns for each command ????

Similar Threads

  1. Add command column in gridpanel
    By tmducit in forum 1.x Help
    Replies: 1
    Last Post: May 27, 2011, 11:27 AM
  2. GridPanel Column Command?
    By peter.campbell in forum 1.x Help
    Replies: 1
    Last Post: Apr 08, 2011, 9:13 AM
  3. get column value with gridpanel gridcommand?
    By danilo in forum 1.x Help
    Replies: 3
    Last Post: Jan 10, 2011, 3:59 PM
  4. [CLOSED] [1.0] GridPanel Group Command (Menu Type ) show/hide on demand
    By webclouder in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 10, 2010, 5:04 PM
  5. [CLOSED] [1.0] - GridPanel Column unable to Hide column
    By drkoh in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 01, 2010, 5:37 PM

Posting Permissions