Feb 08, 2011, 1:59 PM
Problem creating Store with JsonReader
Hi, I wonder if you can help?
I am trying to populate an ext:Store element with data from my Model and read the data into a JsonReader.
I have tried a number of things but the latest is -
The code to populate my Store:
<script runat="server">
protected void Page_Load(object sender, EventArgs e){
if (!X.IsAjaxRequest) {
List<Object> theData = new List<Object>();
theData.AddRange(Model.MasterAccount.client_accoun ts);
this.individualAccountsStore.DataSource = new AjaxStoreResult(Model.MasterAccount.client_account s.AsEnumerable());
The code above causes the exception: Invalid datasource type. "The data source must be of type IListSource, IEnumerable or IDatasource"
The offending code does apper to be creating an IDatasource so I'm a bit perplexed.
this.individualAccountsStore.DataBind();
}
}
</script>
The code for my JsonReader - though currently it's not reaching here.
<ext:Store ID="individualAccountsStore" runat="server">
<Reader>
<ext:JsonReader Root="data">
<Fields>
<ext:RecordField Name="AccountTypeId" Type="int" Mapping="AccountTypeId" />
<ext:RecordField Name="Title" Type="String" Mapping="Title" />
<ext:RecordField Name="FirstNames" Type="String" Mapping="FirstNames" />
<ext:RecordField Name="Surname" Type="String" Mapping="Surname" />
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
Thank you
I am trying to populate an ext:Store element with data from my Model and read the data into a JsonReader.
I have tried a number of things but the latest is -
The code to populate my Store:
<script runat="server">
protected void Page_Load(object sender, EventArgs e){
if (!X.IsAjaxRequest) {
List<Object> theData = new List<Object>();
theData.AddRange(Model.MasterAccount.client_accoun ts);
this.individualAccountsStore.DataSource = new AjaxStoreResult(Model.MasterAccount.client_account s.AsEnumerable());
The code above causes the exception: Invalid datasource type. "The data source must be of type IListSource, IEnumerable or IDatasource"
The offending code does apper to be creating an IDatasource so I'm a bit perplexed.
this.individualAccountsStore.DataBind();
}
}
</script>
The code for my JsonReader - though currently it's not reaching here.
<ext:Store ID="individualAccountsStore" runat="server">
<Reader>
<ext:JsonReader Root="data">
<Fields>
<ext:RecordField Name="AccountTypeId" Type="int" Mapping="AccountTypeId" />
<ext:RecordField Name="Title" Type="String" Mapping="Title" />
<ext:RecordField Name="FirstNames" Type="String" Mapping="FirstNames" />
<ext:RecordField Name="Surname" Type="String" Mapping="Surname" />
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
Thank you