Results 1 to 5 of 5

Thread: Ext.Net Store.loadData

  1. #1
    Member
    Join Date
    Jul 2009
    Posts
    72

    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?
    Code:
    // 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

    Code:
    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.

  2. #2
    Ext.NET - Support Team Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    27,205

    RE: Ext.Net Store.loadData

    Hello, cleve!

    I think I can help if you let me see at the rest part of you code to reproduce the errors you mentioned.
    Daniil
    Ext.NET, Inc.
    Support Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | Twitter | Jobs

  3. #3
    Ext.NET - Support Team Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    27,205

    RE: Ext.Net Store.loadData

    Hi again.This code looks a little bit strange.

    Code:
     TwoStoreResponseData msData = new TwoStoreResponseData();
    msData.Total = qMappings.Count();
    msData.Data = JSON.Serialize(qMappings.ToList());
    store.LoadData(msData.ToString(), true);
    Try to replace this by the following code.

    Code:
    store.DataSource = qMappings.ToList();
    store.DataBind();
    Did it help you?

    P.S. It seems the Help forum is more appropriate for this topic than the Bugs forum.

    Daniil
    Ext.NET, Inc.
    Support Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | Twitter | Jobs

  4. #4
    Member
    Join Date
    Jul 2009
    Posts
    72

    RE: Ext.Net Store.loadData



    Hi Daniil,

    Thanks for your reply. The code you appended works fine if I erase the reader settings (Root and TotalProperty). I think I have serval points to add on this post for the reason why I think it is more likely a bug.

    The class definition which you can find as "TwoStoreReponseData" is a sub-class derived from "StoreResponseData" whose "ToString()" function produces a Json format with root name "data" and "total" property. StoreReponseData is a usful class I use in the project to generate Json-based MVC action results (transmitting a zipped store data).

    That's why I want to generalize this format to let the rest of my store definitions confine with this usage convention.

    - On previous version (0.8.2) afore server-side script works fine and the rendered JS scripts are correctly mapped to store.loadData(jsonObject, isAppended). But 1.0 version renders another format which is store.loadData(jsonString, isAppended). To translate jsonString to jsonObject, I think a wrap "Ext.decode()" is required. If not, reader's getRoot function will generate an error. That's the one I mentioned at the original post saying some errors occurred.

    - At 1.0 version, StoreReponseData.ToString() changed the totalProperty name which is from "totalCount" to "total". Other implementation of it remains the same. So when I changed the way I initialize the store with the following:

    Code:
                // Your solution
                // store.DataSource = qMappings.ToList();
                // store.DataBind();
    
    
                store.AutoLoad = true;
                store.SetDataFromJson(msData.ToString());
    It works fine! That means the Json format is still accepted by the store and reader definition.

    - Furtherly when I double check the way DataBind or SetDataFromJson, I found they use different mapping to client-side JS script render, comparing with LoadData. They both use Ext.data.PagingMemoryProxy to create a Json block proxy for reader to read.

    So in conclusion, StoreReponseData is producing a correct Json string and Store reader still accept the way to read the string if reader and root are correctly specified. Problematic is LoadData, which is at server-side should render a client-side loadData function without quoting the string object put to server-side function call.


  5. #5
    Ext.NET - Support Team Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    27,205

    RE: Ext.Net Store.loadData

    Hello, cleve!

    Maybe you are right, maybe not:) I think the creators of this toolkit can answer on this question - it's a bug or not? Perhaps, they have already answered on it because this topic is moved to Help from Bug forum:)
    Daniil
    Ext.NET, Inc.
    Support Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | Twitter | Jobs

Similar Threads

  1. [CLOSED] [2.0] Razor and Store LoadData
    By Timothy in forum 2.x Premium Help
    Replies: 8
    Last Post: Jun 28, 2012, 6:45 PM
  2. Store.loadData()
    By glenh in forum 1.x Help
    Replies: 2
    Last Post: Dec 05, 2011, 3:34 AM
  3. About Ext.Net Store.loadData
    By caoit in forum 1.x Help
    Replies: 0
    Last Post: Apr 26, 2011, 2:41 AM
  4. [1.0] Store.LoadData vs DataBind
    By Kam in forum 1.x Help
    Replies: 1
    Last Post: Apr 19, 2011, 11:00 AM
  5. [CLOSED] Store loadData() wierd error.
    By capecod in forum 1.x Premium Help
    Replies: 9
    Last Post: Nov 10, 2010, 8:46 AM

Posting Permissions