PDA

View Full Version : [CLOSED] Populating GridPanel Store from CodeBehind



elisa
Aug 13, 2014, 2:07 PM
I'm trying to populate the Store ServerDetailsStore in this pop-up window:


<ext:Window runat="server" ID="DetailsPopUp" Region="Center" Width="1225" Height="525"
Hidden="true" Layout="VBoxLayout" Maximizable="true" TitleAlign="Center" TitleCollapse="true">
<LayoutConfig>
<ext:VBoxLayoutConfig Align="Stretch" />
</LayoutConfig>
<Items>
<ext:Panel runat="server" Layout="HBoxLayout" Flex="1">
<LayoutConfig>
<ext:HBoxLayoutConfig Align="Stretch" />
</LayoutConfig>
<Items>
<ext:GridPanel ID="DetailsGrid" runat="server" Title="Server Details" Frame="true"
Flex="1" HideHeaders="true">
<Store>
<ext:Store ID="ServerDetailsStore" runat="server" AutoLoad="true">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="FIELD" Type="String" />
<ext:ModelField Name="VALUE" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" DataIndex="FIELD" Width="150" />
<ext:Column runat="server" DataIndex="VALUE" Flex="1" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel runat="server" EnableTextSelection="true" />
</SelectionModel>
<View>
<ext:GridView runat="server" EnableTextSelection="true" />
</View>
</ext:GridPanel>
<ext:GridPanel ID="FilesystemGrid" runat="server" Title="Filesystem" Frame="true"
Flex="1">
</ext:GridPanel>
</Items>
</ext:Panel>
<ext:Panel runat="server" Layout="HBoxLayout" Flex="1">
<LayoutConfig>
<ext:HBoxLayoutConfig Align="Stretch" />
</LayoutConfig>
<Items>
<ext:GridPanel ID="CPUGrid" runat="server" Title="CPU" Frame="true" Flex="1">
</ext:GridPanel>
<ext:GridPanel ID="MemoryGrid" runat="server" Title="Memory" Frame="true" Flex="1">
</ext:GridPanel>
</Items>
</ext:Panel>
</Items>
</ext:Window>


There is a DirectMethod that is called when user clicks a button to pop-up the window:


[DirectMethod]
public void PopulateDetailsPopUp(string ComponentID, string Hostname, string DataCenter, string Environment, string OperatingSystem, string PhysicalVirtual)
{
this.ServerDetailsStore.DataSource = new object[]
{
new object[] { "Host Name", Hostname },
new object[] { "Datacenter", DataCenter },
new object[] { "Environment", Environment },
new object[] { "Operating System", OperatingSystem },
new object[] { "Physical/Virtual", PhysicalVirtual }
};
this.ServerDetailsStore.DataBind();

this.DetailsPopUp.Show();
}


The window pops up and the grid shows 5 rows where the data should be, but there is no data. :(
http://forums.ext.net/attachment.php?attachmentid=14201&stc=1

Daniil
Aug 14, 2014, 5:14 AM
Hi @elisa,

I think you should define an ArrayReader for the Store. Please try.

elisa
Aug 14, 2014, 3:33 PM
That worked, thanks.
I was following this example (http://examples2.ext.net/#/GridPanel/ArrayGrid/Simple/) so I'm not sure what the difference is...?

Daniil
Aug 14, 2014, 3:44 PM
Well, the difference that you bind the data during a DirectEvent, but it is done initially in that example.

Though, I would define an ArrayReader in that example as well.