title: Ext.NET GridPanel with XML datasource
body: <p>In the .aspx file I have:</p>
  
  <pre><code>&lt;asp:XmlDataSource runat="server" ID="XmlDS" /&gt;
  ...
  &lt;ext:ResourceManager ID="ResourceManager1" runat="server" /&gt;
  &lt;ext:GridPanel
                                             ID="GridPanel1"
                                             runat="server"
                                             StripeRows="true"
                                             Title="User Permissions"
                                             TrackMouseOver="true"
                                             Width="600"
                                             Height="350"
                                             AutoExpandColumn="Item"&gt;
                                             &lt;Store&gt;
                                                  &lt;ext:Store ID="Store1" runat="server"&gt;
                                                       &lt;Reader&gt;
                                                           &lt;ext:ArrayReader&gt;
                                                               &lt;Fields&gt;
                                                                     &lt;ext:RecordField Name="Item" /&gt; 
                                                                     &lt;ext:RecordField Name="Access1" Type="Boolean" /&gt;
                                                                     &lt;ext:RecordField Name="Access2" Type="Boolean" /&gt;
                                                                     &lt;ext:RecordField Name="Access3" Type="Boolean" /&gt;
                                                                     &lt;ext:RecordField Name="Access4" Type="Boolean" /&gt;
                                                                     &lt;ext:RecordField Name="Access5" Type="Boolean" /&gt;
                                                               &lt;/Fields&gt;
                                                           &lt;/ext:ArrayReader&gt;
                                                       &lt;/Reader&gt;
                                                  &lt;/ext:Store&gt;
                                            &lt;/Store&gt;
                                            &lt;ColumnModel ID="ColumnModel1" runat="server"&gt;
                                                &lt;Columns&gt;
                                                    &lt;ext:Column ColumnID="Item" Header="Item" DataIndex="Item" /&gt;
                                                    &lt;ext:Column ColumnID="Access1" Header="Access1" DataIndex="Access1" /&gt;
                                                    &lt;ext:Column ColumnID="Access2" Header="Access2" DataIndex="Access2" /&gt;
                                                    &lt;ext:Column ColumnID="Access3" Header="Access3" DataIndex="Access3" /&gt;
                                                    &lt;ext:Column ColumnID="Access4" Header="Access4" DataIndex="Access4" /&gt;
                                                    &lt;ext:Column ColumnID="Access5" Header="Access5" DataIndex="Access5" /&gt;
                                                &lt;/Columns&gt;
                                            &lt;/ColumnModel&gt;
                                            &lt;SelectionModel&gt;
                                                &lt;ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true" /&gt;
                                            &lt;/SelectionModel&gt;
                                 &lt;/ext:GridPanel&gt;
  </code></pre>
  
  <p>Note that I have no experience with ExtJS/Ext.NET so the GridPanel code was used according to how the panel is used on <a href="http://forums.ext.net/showthread.php?10205-More-Information-Required" rel="nofollow noreferrer">http://forums.ext.net/showthread.php?10205-More-Information-Required</a></p>
  
  <p>There it is using a JSON object. Before attempting the whole ExtJS method I found that it can use XML or JSON. When a drop down list's selected index changes, it loads that user's permissions and adds it to a DataTable object (rows are string, bool, bool, bool, bool, bool), which I have successfully created the XML object for. The function returns a string (tempData) which is the address for the XML document in question. so here is the code where I'm not getting any result to load in the grid:</p>
  
  <pre><code>if (tempData != String.Empty)
          {
              XmlDS.DataFile = tempData;
              Store1.DataSource = XmlDS;
              Store1.DataBind();
              GridPanel1.Reload();
              File.Delete(tempData);
          }
  </code></pre>
  
  <p><strike>tried GridPanel1.RefreshView() and it said it requires an AJAX Request and couldn't find anything on it. Reload() doesn't do what I am attempting to make it do (doesn't throw an exception like RefreshView() and passes right through fine, but doesn't load the data.</strike></p>
  
  <p>I'm thinking the GridPanel stuff was borrowed from where a JSON object was used, and perhaps the fact that a asp:XmlDataSource object isn't usable for it. But I really don't have a clue to how to get it to load this data</p>
  
  <p>I have also tried setting the datasource to the table itself, which loads data, but it loads the string values as empty strings and loads all of the boolean values as false.</p>
  
  <p>I appreciate any help you can give. If more info is needed, please let me know.</p>
  
  <p>Thanks,</p>
  
  <hr>
  
  <p>I cannot get it to load the XML for the life of me. I found an example on the ext.net site (the same one given by Geoffrey) that uses .xml and .xsl files. I generate the .xml document using c# but I don't have a .xsl file that goes with it (nor am I sure how a .xsl document should be structured to try and generate one).</p>
  
  <p>So I have attempted to pass a DataTable object with 15 rows. End result:</p>
  
  <p><img src="https://i.stack.imgur.com/tsg8S.png" alt="enter image description here"></p>
  
  <p>One thing that is neat to note is that while it may not have the data, it does contain all 15 rows. I'm assuming it did try to load the dataset but just failed.</p>
  
  <p>In the .aspx file I have:</p>
  
  <pre><code>&lt;ext:ResourceManager ID="ResourceManager1" runat="server" /&gt;
                                    &lt;ext:GridPanel
                                             ID="GridPanel1"
                                             runat="server"
                                             StripeRows="true"
                                             Title="User Permissions"
                                             TrackMouseOver="true"
                                             Width="600"
                                             Height="350"
                                             AutoExpandColumn="Item"&gt;
                                             &lt;Store&gt;
                                                  &lt;ext:Store ID="Store1" runat="server"&gt;
                                                       &lt;Reader&gt;
                                                           &lt;ext:JsonReader&gt;
                                                               &lt;Fields&gt;
                                                                     &lt;ext:RecordField Name="Item" /&gt; 
                                                                     &lt;ext:RecordField Name="Access1" Type="Boolean" /&gt;
                                                                     &lt;ext:RecordField Name="Access2" Type="Boolean" /&gt;
                                                                     &lt;ext:RecordField Name="Access3" Type="Boolean" /&gt;
                                                                     &lt;ext:RecordField Name="Access4" Type="Boolean" /&gt;
                                                                     &lt;ext:RecordField Name="Access5" Type="Boolean" /&gt;
                                                               &lt;/Fields&gt;
                                                           &lt;/ext:JsonReader&gt;
                                                       &lt;/Reader&gt;
                                                  &lt;/ext:Store&gt;
                                            &lt;/Store&gt;
                                            &lt;ColumnModel ID="ColumnModel1" runat="server"&gt;
                                                &lt;Columns&gt;
                                                    &lt;ext:Column ColumnID="Item" Header="Item" DataIndex="Item" /&gt;
                                                    &lt;ext:CheckColumn ColumnID="Access1" Header="Access1" DataIndex="Access1" Editable="true" Width="40px" /&gt; 
                                                    &lt;ext:CheckColumn ColumnID="Access2" Header="Access2" DataIndex="Access2" Editable="true" Width="40px" /&gt;
                                                    &lt;ext:CheckColumn ColumnID="Access3" Header="Access3" DataIndex="Access3" Editable="true" Width="40px" /&gt;
                                                    &lt;ext:CheckColumn ColumnID="Access4" Header="Access4" DataIndex="Access4" Editable="true" Width="40px" /&gt;
                                                    &lt;ext:CheckColumn ColumnID="Access5" Header="Access5" DataIndex="Access5" Editable="true" Width="40px" /&gt;
                                                &lt;/Columns&gt;
                                            &lt;/ColumnModel&gt;
                                            &lt;SelectionModel&gt;
                                                &lt;ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true" /&gt;
                                            &lt;/SelectionModel&gt;
                                 &lt;/ext:GridPanel&gt;
  </code></pre>
  
  <p>And this is the part where I'm attempting to load the data (tempData is the string address for the XML document as the xml is generated after a drop down list selection).</p>
  
  <pre><code>List&lt;List&lt;Object&gt;&gt; PermissionList = BL.Person.getPermissionsList(Convert.ToInt32(ddlUserName.SelectedValue));
  
          DataTable table = BL.Data.CreatePermissionsTable(PermissionList);
  
          string tempData = BL.Data.CreateXML(table, "Permission", Convert.ToInt32(ddlUserName.SelectedValue));
  
          if (tempData != String.Empty)
          {
              ChangeAccess.Style.Add("display", "block");
              Store1.DataSource = table;
              Store1.DataBind();
              File.Delete(tempData);
          }
  </code></pre>
  
  <p>note that when using the DataSet as the object, the string tempdata/file.delete are fairly pointless.</p>
  
  <p>The end goal is to use XML but if it requires using DataTable in the meantime, then I'll go that route. The reason I'm not currently using the json/ method is that the data is, as mentioned, generated from the code behind (it generates 'true' values in the existence of a value in the useraccess for item/personid/accesslevel table, false otherwise. Not actual database entries).</p>
  
  <p>Thanks again,</p>
  
  <hr>
  
  <p>XML structure:</p>
  
  <pre><code>&lt;permissions&gt;
      &lt;permission&gt;
          &lt;Item&gt;Process 1&lt;/Item&gt;
          &lt;Access1&gt;True&lt;/Access1&gt;
          &lt;Access2&gt;True&lt;/Access2&gt;
          &lt;Access3&gt;False&lt;/Access3&gt;
          &lt;Access4&gt;False&lt;/Access4&gt;
          &lt;Access5&gt;False&lt;/Access5&gt;
      &lt;/permission&gt;
      &lt;permission&gt;
          &lt;Item&gt;Process 2&lt;/Item&gt;
          &lt;Access1&gt;True&lt;/Access1&gt;
          &lt;Access2&gt;True&lt;/Access2&gt;
          &lt;Access3&gt;True&lt;/Access3&gt;
          &lt;Access4&gt;False&lt;/Access4&gt;
          &lt;Access5&gt;False&lt;/Access5&gt;
      &lt;/permission&gt;
  &lt;/permissions&gt;
  </code></pre>
  
  <p>I attempted to reload the .XML again and this time it seems to be pulling, sort of, the rows generated are somewhere in the neighborhood of 100 rows returned (way beyond the 15 permission elements).</p>
  
  <p>Note that I do not have a .xsl file for TransformFile. This won't be an issue I hope?</p>
  
  <p>I need to log into the desktop with the actual code, I'll try and get the render thing you requested. Thanks for the help Geoffrey.</p>
  
  <hr>
  
  <p>Last edit I swear</p>
  
  <p>Between Geoffrey's help and a bit of "what does the example have that mine doesn't?" I was able to get it to work after a few steps:</p>
  
  <p>1) Must generate a .XSL file to give structure to the .XML file. I used the plants.xsl file as a template.</p>
  
  <p>2) in the event that sets my XmlDS object, I changed it to this:</p>
  
  <pre><code>if (tempData != String.Empty)
          {
  
              ChangeAccess.Style.Add("display", "block");
              XmlDS.DataFile = tempData;
              XmlDS.TransformFile = tempData.Remove(tempData.LastIndexOf('\\')) + "\\Permissions.xsl";
              Store1.DataSource = XmlDS;
              Store1.DataBind();
              File.Delete(tempData);
          } 
  </code></pre>
  
  <p>3) At this point, I knew it was loading the data as the Items were now displaying properly unfortunately the checkboxes weren't. So I made the function that generates my string/bool/bool/bool/bool/bool object list to replace the bool value with a 1 or a 0. So my xml was now 1 for a true value, for example. Works like a charm now.</p>
  
  <p>Now onto the next step of pulling data from the Store when a button event is clicked to a XML file with duplicate structure.</p>
  
  <p>Thanks again Geoffrey</p>