[CLOSED] Command Column

  1. #1

    [CLOSED] Command Column

    hi,

    Please let me know if there is a way to let the Text property of a command in a Command column use the value of the column dataindex field and also make the command fit the width of the column.

    below i am using the SplitCommand and would like the text be the {Name} and also make the command re-size to fit the column width.


     
    <ext:CommandColumn  DataIndex="Name" Header ="Name"  Width="80">
    <Commands>
      <ext:SplitCommand Text='{Name}' AutoDataBind ="true"  CommandName ="GridView">
    <Menu>
    <Items>
    <ext:MenuCommand Text="View in grid view" CommandName="GridView">
    </ext:MenuCommand>
    <ext:MenuCommand Text="View in list view" CommandName="ListView">
      </ext:MenuCommand>
     </Items>
    </Menu>
     </ext:SplitCommand>
     </Commands>
     </ext:CommandColumn>
    Last edited by Daniil; Aug 18, 2012 at 9:38 AM. Reason: [CLOSED]
  2. #2
    Quote Originally Posted by RCM View Post
    Please let me know if there is a way to let the Text property of a command in a Command column use the value of the column dataindex field
    Please set up it within a PrepareToolbar handler using the setText method.
    https://examples1.ext.net/#/GridPane...epare_Toolbar/

    Quote Originally Posted by RCM View Post
    make the command re-size to fit the column width.
    I can suggest the following solution.

    1. Set up PrepareToolbar for the CommandColumn.
    <PrepareToolbar Fn="prepare" />
    The handler is:
    var prepare = function (grid, toolbar, rowIndex, record) {
        var firstButton = toolbar.items.get(0),
            cm = grid.getColumnModel(),
            width = cm.getColumnWidth(cm.getIndexById("CommandColumn1"));
                
        firstButton.setWidth(width);
    };
    2. Define the following ColumnResize listener for the GridPanel.
    <ColumnResize Handler="var column = this.getColumnModel().getColumnAt(columnIndex);
                                           
                           if (column.isColumnPlugin && column.cache) {
                               this.getView().refresh();
                           }" />
  3. #3

    hi

    Thanks for the quick reply. One other thing, is it possible to make the CommanColumn sortable, I have the sort property to true, but I cannot sort using the column and i can't get the value in the column left aligned.. Please the attached screen shot of what i am trying to achieve. Am I using the right controls.

    Click image for larger version. 

Name:	Column Image.png 
Views:	145 
Size:	16.5 KB 
ID:	4637
  4. #4
    Generally, CommandColumn doesn't support sorting due to the fact that there is DataIndex.

    But in your case, since you use a record field for commands names, you could try to set up this record field as DataIndex.

    Also, needs to set up Sortable via CustomConfig.

    Here is an example where the things appear to be working.

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.GridPanel1.GetStore();
                store.DataSource = new object[] 
                { 
                    new object[] { "test1", "command 3" },
                    new object[] { "test2", "command 2" },
                    new object[] { "test3", "command 1" }
                };
                store.DataBind();
            }
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.NET Example</title>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
        <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
            <Store>
                <ext:Store runat="server">
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="test" />
                                <ext:RecordField Name="commandName" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column Header="Test" DataIndex="test" />
                    <ext:CommandColumn Header="Commands" DataIndex="commandName">
                        <CustomConfig>
                            <ext:ConfigItem Name="sortable" Value="true" Mode="Raw" />
                        </CustomConfig>
                        <Commands>
                            <ext:GridCommand />
                        </Commands>
                        <PrepareToolbar Handler="toolbar.items.get(0).setText(record.get('commandName'));" />
                    </ext:CommandColumn>
                </Columns>
            </ColumnModel>
        </ext:GridPanel>
    </body>
    </html>

Similar Threads

  1. [CLOSED] Disable command column
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 07, 2011, 3:33 PM
  2. problem with fixing command column
    By oseqat in forum 1.x Help
    Replies: 6
    Last Post: Jul 25, 2011, 3:13 PM
  3. Add command column in gridpanel
    By tmducit in forum 1.x Help
    Replies: 1
    Last Post: May 27, 2011, 11:27 AM
  4. GridPanel Column Command?
    By peter.campbell in forum 1.x Help
    Replies: 1
    Last Post: Apr 08, 2011, 9:13 AM
  5. command column messing up grid column
    By wp_joju in forum 1.x Help
    Replies: 2
    Last Post: Dec 08, 2010, 6:40 AM

Tags for this Thread

Posting Permissions