Jun 23, 2010, 11:51 AM
Ext.Net Store.loadData
I tried to make an initialization of Store with some initial data loaded by scripts. Weird is that I coded some server-side scripts but rendered client scripts like the following. It generates errors. Any ideas?
// server side
store.AutoLoad = false;
JsonReader reader = new JsonReader()
{
Root = "data",
TotalProperty = "total"
};
reader.Fields.Add(
new RecordField() { Name = "MetaInfo", Type = RecordFieldType.String });
reader.Fields.Add(
new RecordField() { Name = "TemplateMetaInfo", Type = RecordFieldType.String });
reader.Fields.Add(
new RecordField() { Name = "RootId", Type = RecordFieldType.String });
store.Reader.Add(reader);
var qMappings =
from mapping in mappingSource
select new
{
MetaInfo = mapping.Key.Key.ToString(),
TemplateMetaInfo = mapping.Key.Value.ToString(),
RootId = mapping.Value.Id.ToISFormatted()
};
TwoStoreResponseData msData = new TwoStoreResponseData();
msData.Total = qMappings.Count();
msData.Data = JSON.Serialize(qMappings.ToList());
store.LoadData(msData.ToString(), true);
While I captured client side scripts by viewing the page source
ctl00_C_dsTypeTemplateMappings.loadData("{data:[{\"MetaInfo\":\"Appointment\",\"TemplateMetaInfo\":\"FormTemplate\",\"RootId\":\"7060898AA5C7445287A055294570DA76\"},{\"MetaInfo\":\"Article\",\"TemplateMetaInfo\":\"FormTemplate\",\"RootId\":\"7060898AA5C7445287A055294570DA76\"},{\"MetaInfo\":\"BitFile\",\"TemplateMetaInfo\":\"FormTemplate\",\"RootId\":\"7060898AA5C7445287A055294570DA76\"},{\"MetaInfo\":\"Customer\",\"TemplateMetaInfo\":\"FormTemplate\",\"RootId\":\"7060898AA5C7445287A055294570DA76\"},{\"MetaInfo\":\"HtmlPeriod\",\"TemplateMetaInfo\":\"FormTemplate\",\"RootId\":\"7060898AA5C7445287A055294570DA76\"},{\"MetaInfo\":\"Person\",\"TemplateMetaInfo\":\"FormTemplate\",\"RootId\":\"7060898AA5C7445287A055294570DA76\"},{\"MetaInfo\":\"Product\",\"TemplateMetaInfo\":\"FormTemplate\",\"RootId\":\"7060898AA5C7445287A055294570DA76\"},{\"MetaInfo\":\"Project\",\"TemplateMetaInfo\":\"FormTemplate\",\"RootId\":\"7060898AA5C7445287A055294570DA76\"}], total: 8}",true);
Isn't that loadData shoud be input with a object parameter instead of string? I placed an Ext.decode() to string then rendered a pretty right result.