Conditionally disabling editable CheckColumn items in GridPanel

  1. #1

    Conditionally disabling editable CheckColumn items in GridPanel

    Hello,

    For context as far as code/xml/etc., refer to Stack Overflow question as Geoffrey helped me with getting it to actually bind.

    So everything is currently functional. I can update the database based on the checkboxes on the grid, I can display everything, etc. However, there is a specific requirement that I'm unsure of how to meet:

    A user may only change the permissions of another user that they themselves have access to.

    I attempted to create a xml document in the same way the target user one was done. Works fine. I attempted to create an ASP XML data source and bind it with that xml document. That works fine. However, at this point I have no idea how to get at this data during runtime so that I can check each of the true/false flags and enable/disable each of the fields respectively. I tried to do a second store, but a gridpanel can only have one so that wasn't going to work.

    So first how do I get at XML data and from there how do I create a javascript function that is run in BeforeEdit to allow/disallow the editting of the fields? It would be nice if it would visually disable the controls but that isn't an absolute requirement.

    Thanks

    Here is the updated code of what I have thus far:

    string tempData = XML.CreateXML(Table.CreatePermissionsTable(Person.getPermissionsList(-1)), "Permission", -1);
    string loggedInRights = XML.CreateXML(Table.CreatePermissionsTable(Person.getPermissionsList(Convert.ToInt32(Session[SESSION_LOGGED_ON_ID]))), "Permission", Convert.ToInt32(Session[SESSION_LOGGED_ON_ID]));
    XmlDS.DataFile = tempData;
    XmlDS.TransformFile = tempData.Remove(tempData.LastIndexOf('\\')) + "\\Permissions.xsl";
    XmlDSLoggedOn.DataFile = loggedInRights;
    XmlDSLoggedOn.TransformFile = tempData.Remove(tempData.LastIndexOf('\\')) + "\\Permissions.xsl";
    Here is an example of the xml that is generated note that there should be one for the target person and one for the person performing the edit:

    <permissions>     
    <permission>         
    <Item>Process 1</Item>         
    <Access1>True</Access1>         
    <Access2>True</Access2>         
    <Access3>False</Access3>         
    <Access4>False</Access4>         
    <Access5>False</Access5>     
    </permission>     
    <permission>         
    <Item>Process 2</Item>         
    <Access1>True</Access1>         
    <Access2>True</Access2>         
    <Access3>True</Access3>         
    <Access4>False</Access4>         
    <Access5>False</Access5>     
    </permission> 
    </permissions>
    and here is the .aspx code related to the grid itself:

    <ext:ResourceManager ID="ResourceManager1" runat="server" />                                   
    <ext:GridPanel                                            
        ID="GridPanel1"                                            
        runat="server"                                            
        StripeRows="true"                                            
        Title="User Permissions"                                            
        TrackMouseOver="true"                                            
        Width="600"                                            
        Height="350"                                            
        AutoExpandColumn="Item">                                             
    <Store>                                                 
    <ext:Store ID="Store1" runat="server">                                                      
    <Reader>                                                          
    <ext:JsonReader>                                                              
    <Fields>                                                                    
    <ext:RecordField Name="Item" />                                                                     
    <ext:RecordField Name="Access1" Type="Boolean" />                                                                    
    <ext:RecordField Name="Access2" Type="Boolean" />                                                                    
    <ext:RecordField Name="Access3" Type="Boolean" />                                                                    
    <ext:RecordField Name="Access4" Type="Boolean" />                                                                    
    <ext:RecordField Name="Access5" Type="Boolean" />                                                              
    </Fields>                                                          
    </ext:JsonReader>                                                      
    </Reader>                                                 
    </ext:Store>                                           
    </Store>                                           
    <ColumnModel ID="ColumnModel1" runat="server">                                               
    <Columns>                                                   
    <ext:Column ColumnID="Item" Header="Item" DataIndex="Item" />                                                   
    <ext:CheckColumn ColumnID="Access1" Header="Access1" DataIndex="Access1" Editable="true" Width="40px" />
    <ext:CheckColumn ColumnID="Access2" Header="Access2" DataIndex="Access2" Editable="true" Width="40px" />
    <ext:CheckColumn ColumnID="Access3" Header="Access3" DataIndex="Access3" Editable="true" Width="40px" />
    <ext:CheckColumn ColumnID="Access4" Header="Access4" DataIndex="Access4" Editable="true" Width="40px" />
    <ext:CheckColumn ColumnID="Access5" Header="Access5" DataIndex="Access5" Editable="true" Width="40px" />
    </Columns>                                           
    </ColumnModel>                                           
    <SelectionModel>                                               
    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true" />
    </SelectionModel>                                
    </ext:GridPanel>
    Last edited by whelaro; Mar 14, 2011 at 5:54 PM. Reason: adding code
  2. #2
    Okay, decided to switch gears as far as how to try and tackle this. I remembered that the grid itself is loaded via a postback as that is when the store is databound. So I figure it should be relatively easy to do this from codebehind. My first instinct is to go to [row][col] in the DataTable and check if it is flagged true, if so GridPanel's [row][col] should be editable, otherwise no. The layout of the table is string / bool / bool/ bool.... and the string items are never to be editted so the logic should be fine.

    How does one access the row/col values of a grid panel on the server side?

    Thanks

Similar Threads

  1. CheckColumn is editable?
    By 78fede78 in forum 1.x Help
    Replies: 2
    Last Post: Jan 18, 2013, 12:46 PM
  2. Editable Checkcolumn gives javascript error
    By Birgit in forum 2.x Help
    Replies: 2
    Last Post: Apr 19, 2012, 11:56 AM
  3. Replies: 3
    Last Post: Feb 22, 2012, 12:56 PM
  4. Replies: 2
    Last Post: Nov 09, 2011, 5:00 AM
  5. Replies: 1
    Last Post: Jan 28, 2009, 7:36 PM

Posting Permissions