[CLOSED] Disable checkbox for some items in gridpanel with selection model

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] Disable checkbox for some items in gridpanel with selection model

    I would like to disable selection for certain rows based on some condition on gridpanel with checkbox selection model. It will be great if you have both - clientside and serverside example.
    Last edited by Daniil; May 05, 2011 at 1:09 PM. Reason: [CLOSED]
  2. #2
    Hi,

    You can do this by returning false from SelectionModel's BeforeRowSelect listener to cancel selecting.
    Last edited by Daniil; May 04, 2011 at 5:11 PM.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    You can do this by returning false from SelectionModel's BeforeRowSelect listener to cancel selecting.
    I'm looking to disable it, not to deselect it
  4. #4
    Please investigate the sample.

    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", "test13" },
                    new object[] { "test12", "test22", "test23" },
                    new object[] { "test13", "test32", "test33" }
                };
                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>
    
        <script type="text/javascript">
            var getRowClass = function (record, index) {
                if (index === 0 || index === 2) {
                    return "my-disabled";
                }
            }
        </script>
    
        <style type="text/css">
            .my-disabled .x-grid3-row-checker {
                filter: alpha(opacity=60);
                opacity: 0.6;
            }
        </style>
    </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:Column Header="Test3" DataIndex="test3" />
                </Columns>
            </ColumnModel>
            <View>
                <ext:GridView runat="server">
                    <GetRowClass Fn="getRowClass" />
                </ext:GridView>
            </View>
            <SelectionModel>
                <ext:CheckboxSelectionModel runat="server">
                    <Listeners>
                        <BeforeRowSelect Handler="return rowIndex !== 0 && rowIndex !== 2;" />
                    </Listeners>
                </ext:CheckboxSelectionModel>
            </SelectionModel>
        </ext:GridPanel>
        </form>
    </body>
    </html>
  5. #5
    Thanks, it works
  6. #6
    Hi,

    I am searching for a similar solution to use in a Checkbox-Tree.

    The problems is that I do not have any Before-Event which fits to my needs and a View with a Tag like GetRowClass is also not available.

    Any ideas?


    Regards,
    Martin

Similar Threads

  1. Question about Checkbox Selection Model in GridPanel
    By slonati_adv in forum 2.x Help
    Replies: 0
    Last Post: Jul 12, 2012, 2:19 PM
  2. [CLOSED] GridPanel with Checkbox Selection Model
    By rnfigueira in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: May 07, 2012, 2:37 PM
  3. Replies: 2
    Last Post: Dec 07, 2011, 7:00 PM
  4. Replies: 4
    Last Post: Oct 06, 2010, 9:08 AM
  5. [CLOSED] Checkbox Selection Model in GridPanel
    By egodoy in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 15, 2009, 10:07 AM

Tags for this Thread

Posting Permissions