[CLOSED] Disabling/Enabling a column on checkbox selection/deselection

  1. #1

    [CLOSED] Disabling/Enabling a column on checkbox selection/deselection

    I have a gridpanel with 2 columns, One is a normal column field and the other is an editor field which i have inside a component column. On checkbox check and uncheck i want to enable and disable the columns. I could get this done on checkbox selection model's select and deselect handler for Component column. But am not being able to do it for the normal columns. Please help in disabling/enabling a normal column on checkbox selection/deselection.

    this is my columns code:
    <ColumnModel ID="ColumnModel1">
                                        <Columns>
                                             <ext:Column ID="Column1" runat="server" DataIndex="Name" Text="Tier2" Width="270" Hideable="false">
                                                
                                            </ext:Column>                                       
                                            <ext:ComponentColumn ID="ComponentColumn2" Namespace="App" runat="server" Editor="true" DataIndex="DisplayName" Width="270" Text="Name As On Metric Upload File" Align="Center">                                            
                                                <Component>
                                                    <ext:TextField ID="TextField2" runat="server" Namespace="App">
                                                        <Listeners>
                                                            <Render Fn="disableTier2DisplayName"></Render>
                                                        </Listeners>
                                                    </ext:TextField>
    
                                                </Component>
                                            </ext:ComponentColumn>
                                        </Columns>
                                    </ColumnModel>
    below is the code am calling on checkbox selection model's deselect handler for disabling the component column:

     function disableDisAssociatedEmployee3() {  
                App.mainContentPlaceholder_ComponentColumn2.getComponent(record).disable();
            }
    Like the way I am accessing component column for disabling, how do i access Column1 to disable it.
    Last edited by Daniil; May 13, 2015 at 8:23 AM. Reason: [CLOSED]
  2. #2
    Hi @arjunrvasisht,

    Please clarify what do you exactly mean by disabling a regular Column? Do you need a cell to look disabled?
  3. #3
    Yes Daniil, I want the cell to be liked disabled.
  4. #4
    I can suggest the following solution.

    Example
    <%@ Page Language="C#" %>
    
    <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[] { "1", "text 1", true },
                    new object[] { "2", "text 2", true },
                    new object[] { "3", "text 3", true }
                };
            }
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    
        <style>
            .cell-disabled {
                color: gray;
            }
        </style>
    
        <script>
            var disableRenderer = function(value, metaData, record) {
                var sm = this.getSelectionModel();
    
                if (record.data.textDisabled) {
                    metaData.innerCls = "cell-disabled";
                }
    
                return value;
            };
    
            var onSelect = function(sm, record, index) {
                record.set("textDisabled", false);
            };
    
            var onDeselect = function(sm, record, index) {
                record.set("textDisabled", true);
            };
        </script>
    </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="id" />
                                    <ext:ModelField Name="text" />
                                    <ext:ModelField Name="textDisabled" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column runat="server" Text="ID" DataIndex="id" />
                        <ext:Column runat="server" Text="Text" DataIndex="text">
                            <Renderer Fn="disableRenderer" />
                        </ext:Column>
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:CheckboxSelectionModel runat="server">
                        <Listeners>
                            <Select Fn="onSelect" />
                            <Deselect Fn="onDeselect" />
                        </Listeners>
                    </ext:CheckboxSelectionModel>
                </SelectionModel>
            </ext:GridPanel>
        </form>
    </body>
    </html>

Similar Threads

  1. Replies: 0
    Last Post: Jan 09, 2014, 10:58 AM
  2. Replies: 1
    Last Post: Sep 27, 2013, 4:06 PM
  3. Replies: 10
    Last Post: Apr 19, 2013, 3:16 PM
  4. [CLOSED] Disabling checkbox grid column cell based on data.
    By SymSure in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 09, 2012, 4:25 AM
  5. [CLOSED] enabling and disabling button code behind
    By gokcemutlu in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 14, 2010, 10:15 AM

Tags for this Thread

Posting Permissions