[CLOSED] CycleButton in gridpanel

  1. #1

    [CLOSED] CycleButton in gridpanel

    Hi
    Is it possible to add a cyclebutton in a gridpanel?

    Thanks
    Mikael
    Last edited by Daniil; Dec 07, 2010 at 10:23 AM. Reason: [CLOSED]
  2. #2
    Hi,

    No, it's not supported at this moment.

    Did you investigate the examples in ../GridPanel/Commands/...? For example,
    https://examples1.ext.net/#/GridPane...u_Row_Command/
  3. #3
    Okay, yes I have looked at that.
    It does not fit what I need, im trying to do like a priority functionallity for each row in the grid, and I want the priority to toggle between each state when i click.

    Thanks anyway.
  4. #4
    Hi,

    You can emulate cycle button. I simplified the example therefore all states are hardcoded
    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.Store1.DataSource = new object[]
                {
                    new object[] { 1, "State1" },
                    new object[] { 2, "State2" },
                    new object[] { 3, "State3" },
                };
    
                this.Store1.DataBind();
            }
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
        
        <script type="text/javascript">
            function prepareCmd(grid, toolbar, rowIndex, record){
                var btn = toolbar.items.get(0),
                    stateId = record.get("stateId");            
                
                btn.setText("Change to State"+stateId);
            }
            
            function doCmd(command, record, rowIndex){
                switch(command){
                    case "s1":
                    case "s2":
                    case "s3":
                        record.set("stateId", command.slice(-1));                    
                        record.set("stateDescr", "State" + command.slice(-1));
                        break;
                    case "CycleState":
                        var stateId = record.get("stateId");
                        
                        if(stateId >= 3){ 
                            stateId = 0;
                        }
                        
                        record.set("stateId", stateId+1);
                        record.set("stateDescr", "State"+(stateId+1));
                        break;
                }
                
                this.getView().refreshRow(rowIndex);
            }
        </script>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            
            <ext:Store ID="Store1" runat="server">
                <Reader>
                    <ext:ArrayReader>
                        <Fields>
                            <ext:RecordField Name="stateId" Type="Int" />
                            <ext:RecordField Name="stateDescr" />
                        </Fields>
                    </ext:ArrayReader>
                </Reader>
            </ext:Store>
    
            <ext:GridPanel 
                ID="GridPanel1" 
                runat="server" 
                StoreID="Store1" 
                Title="Menu Row Command" 
                Width="600" 
                Height="300"
                >
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:Column Header="stateDescr" Width="260" DataIndex="stateDescr" />
                        
                        <ext:CommandColumn Width="150">
                            <Commands>                            
                                <ext:SplitCommand Icon="ArrowRotateClockwise" CommandName="CycleState">
                                    <Menu EnableScrolling="false">
                                        <Items>
                                            <ext:MenuCommand Text="State 1" CommandName="s1" />
                                            <ext:MenuCommand Text="State 2" CommandName="s2" />
                                            <ext:MenuCommand Text="State 3" CommandName="s3" />
                                        </Items>
                                    </Menu>
                                    <ToolTip Text="Cycle" />
                                </ext:SplitCommand>
                            </Commands>
                            
                            <PrepareToolbar Fn="prepareCmd" />
                        </ext:CommandColumn>
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel runat="server" SingleSelect="true" />
                </SelectionModel>
                <Listeners>
                    <Command Fn="doCmd" />
                </Listeners>
            </ext:GridPanel>  
        </form>
    </body>
    </html>
  5. #5
    Cool
    Thanks Ill try this!

Similar Threads

  1. [CLOSED] CycleButton - onclientclick
    By SouthDeveloper in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 04, 2011, 8:21 PM
  2. [CLOSED] [1.0] CycleButton in MVC
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Aug 12, 2010, 2:03 PM
  3. How to - Get Value of CycleButton?
    By Tbaseflug in forum 1.x Help
    Replies: 7
    Last Post: Sep 02, 2009, 10:25 AM
  4. CycleButton
    By olimpia in forum 1.x Help
    Replies: 2
    Last Post: Jul 27, 2009, 2:10 PM
  5. [CLOSED] CycleButton
    By Ben in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Mar 03, 2009, 9:31 AM

Posting Permissions