[CLOSED] checking a grid checkbox with the spacebar

  1. #1

    [CLOSED] checking a grid checkbox with the spacebar

    I have a grid with a checkbox column that is tired to a datafield.How can I use the arrow key to step through each of the records and use the spacebar to select or deselect the checkbox.


    Regards
    Last edited by Daniil; Jun 13, 2011 at 3:48 PM. Reason: [CLOSED]
  2. #2
    Hi,

    To catch arrows and space bar, please use KeyMap of GridPanel.

    You can be interested to investigate how moving on Enter is implemented, see the sources of:
    http://dev.sencha.com/deploy/ext-3.3.1/docs/?class=Ext.grid.RowSelectionModel&member=moveEdito rOnEnter
  3. #3
    Please can you provide me with a sample code for the Grid KeyMap for the arrow key and space bar pressing
  4. #4
    Here you are.

    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[] { "test11", "test12", true },
                    new object[] { "test12", "test22", false },
                    new object[] { "test13", "test32", true }
                };
                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>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
            <Store>
                <ext:Store runat="server">
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="test1" />
                                <ext:RecordField Name="test2" />
                                <ext:RecordField Name="test3" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column Header="Test1" DataIndex="test1" />
                    <ext:Column Header="Test2" DataIndex="test2" />
                    <ext:CheckColumn Header="Test3" DataIndex="test3" />
                </Columns>
            </ColumnModel>
            <SelectionModel>
                <ext:RowSelectionModel runat="server" />
            </SelectionModel>
            <KeyMap>
                <ext:KeyBinding>
                    <Keys>
                        <ext:Key Code="SPACE" />
                    </Keys>
                    <Listeners>
                        <Event Handler="var sm = GridPanel1.selModel,
                                            r = sm.getSelected();
                                        if (r) {
                                            r.set('test3', !r.get('test3'));
                                        }
                                        if (!sm.selectNext()) {
                                            sm.selectFirstRow();   
                                        }" />
                    </Listeners>
                </ext:KeyBinding>
            </KeyMap>
        </ext:GridPanel>
        </form>
    </body>
    </html>

Similar Threads

  1. [CLOSED] TreePanel CheckNodes Null when checking them from codebehind
    By gs_user in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 25, 2012, 6:28 PM
  2. Dynamic checking in a CheckboxSelectionModel.
    By abelvn in forum 1.x Help
    Replies: 2
    Last Post: May 24, 2012, 7:58 PM
  3. Replies: 5
    Last Post: Dec 26, 2011, 5:39 AM
  4. Replies: 1
    Last Post: Jul 24, 2011, 10:59 AM
  5. Checking grid panel items
    By ranganath in forum 1.x Help
    Replies: 0
    Last Post: May 19, 2009, 5:54 AM

Tags for this Thread

Posting Permissions