PDA

View Full Version : I can't select item when i load my store



July171292
Feb 25, 2015, 3:17 PM

RCN
Feb 25, 2015, 7:06 PM
Let me know whether the following example helps you. That's how i would implement it, if i understand your scenario correctly.



<!DOCTYPE html>
<html>
<head runat="server">
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:ComboBox FieldLabel="Field 1" ID="Field1" runat="server">
<Items>
<ext:ListItem Text="Ext.NET" Value="1" />
<ext:ListItem Text="Sencha" Value="2" />
<ext:ListItem Text="Microsoft" Value="3" />
</Items>
<Listeners>
<Select Handler="#{_str}.loadPage(1)" />
</Listeners>
</ext:ComboBox>
<ext:GridPanel Title="Ext.NET" Border="true" Width="500" Height="400" runat="server">
<Store>
<ext:Store ID="_str" AutoLoad="true" runat="server">
<Proxy>
<ext:AjaxProxy Url="~/Example/LoadFakeRecords/">
<Reader>
<ext:JsonReader RootProperty="data" />
</Reader>
</ext:AjaxProxy>
</Proxy>
<Model>
<ext:Model IDProperty="ID" runat="server">
<Fields>
<ext:ModelField Name="ID" Type="String" />
<ext:ModelField Name="Name" Type="String" />
</Fields>
</ext:Model>
</Model>
<Parameters>
<ext:StoreParameter Name="field1" Value="#{Field1}.getValue()" Mode="Raw" />
</Parameters>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column Text="ID" DataIndex="ID" runat="server" />
<ext:Column Text="Name" Flex="1" DataIndex="Name" runat="server" />
</Columns>
</ColumnModel>
</ext:GridPanel>
</body>
</html>




namespace SandBox.Controllers
{
public class ExampleController : System.Web.Mvc.Controller
{
public ActionResult Index()
{
return View();
}

public StoreResult LoadFakeRecords(Nullable<int> field1)
{
List<Entity> lst = new List<Entity>();

for (int index = 1; index < 16; index++)
{
lst.Add(new Entity
{
ID = index,
Name = string.Format("Name - {0:00} - {1}", index, DateTime.Now.ToLongTimeString())
});
}

return new StoreResult(lst, lst.Count());
}
}

[Serializable]
public class Entity
{
public int ID { get; set; }

public string Name { get; set; }
}
}