Mar 14, 2011, 5:34 PM
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:
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