EXT.NET v3.0 BETA RELEASED!
Now with Tablet Support!
Ext.NET v3.0 Beta is here with lots of new cool features and now with tablet support! Check Examples Explorer now to see it in action or download and test it yourself for free!
Results 1 to 8 of 8

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

  1. #1
    Member
    Join Date
    Oct 2010
    Posts
    137

    [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 2:09 PM. Reason: [CLOSED]

  2. #2
    Ext.NET - Support Team Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    28,033
    Hi,

    You can do this by returning false from SelectionModel's BeforeRowSelect listener to cancel selecting.
    Last edited by Daniil; May 04, 2011 at 6:11 PM.
    Daniil
    Ext.NET, Inc.
    Support Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | Twitter | Jobs

  3. #3
    Member
    Join Date
    Oct 2010
    Posts
    137
    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
    Ext.NET - Support Team Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    28,033
    Please investigate the sample.

    Example
    Code:
    <%@ 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>
    Daniil
    Ext.NET, Inc.
    Support Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | Twitter | Jobs

  5. #5
    Member
    Join Date
    Oct 2010
    Posts
    137
    Thanks, it works

  6. #6
    Premium Member
    Join Date
    Dec 2008
    Location
    Cologne, Germany
    Posts
    386
    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

  7. #7
    Ext.NET - Support Team Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    28,033
    Hi,

    Please start a new thread with a link on this thread.
    Daniil
    Ext.NET, Inc.
    Support Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | Twitter | Jobs

  8. #8
    Ext.NET - Support Team Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    28,033
    Here is the update example for v2 (tested with v2.5.1).

    Example
    Code:
    <%@ 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" }
                };
            }
        }
    </script>
     
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.Net Example</title>
     
        <script>
            var getRowClass = function (record, index) {
                if (index === 0 || index === 2) {
                    return "my-disabled";
                }
            }
        </script>
     
        <style>
            .my-disabled .x-grid-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">
                <Store>
                    <ext:Store runat="server">
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="test1" />
                                    <ext:ModelField Name="test2" />
                                    <ext:ModelField Name="test3" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column runat="server" Text="Test1" DataIndex="test1" />
                        <ext:Column runat="server" Text="Test2" DataIndex="test2" />
                        <ext:Column runat="server" Text="Test3" DataIndex="test3" />
                    </Columns>
                </ColumnModel>
                <View>
                    <ext:GridView runat="server">
                        <GetRowClass Fn="getRowClass" />
                    </ext:GridView>
                </View>
                <SelectionModel>
                    <ext:CheckboxSelectionModel runat="server">
                        <Listeners>
                            <BeforeSelect Handler="return index !== 0 && index !== 2;" />
                        </Listeners>
                    </ext:CheckboxSelectionModel>
                </SelectionModel>
            </ext:GridPanel>
        </form>
    </body>
    </html>
    Daniil
    Ext.NET, Inc.
    Support Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | Twitter | Jobs

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, 3:19 PM
  2. [CLOSED] GridPanel with Checkbox Selection Model
    By rnfigueira in forum 1.x Premium Help
    Replies: 5
    Last Post: May 07, 2012, 3:37 PM
  3. Replies: 2
    Last Post: Dec 07, 2011, 8:00 PM
  4. Replies: 4
    Last Post: Oct 06, 2010, 10:08 AM
  5. [CLOSED] Checkbox Selection Model in GridPanel
    By egodoy in forum 1.x Premium Help
    Replies: 2
    Last Post: Dec 15, 2009, 11:07 AM

Tags for this Thread

Posting Permissions