Use a Store to send data to a page.

  1. #1

    Use a Store to send data to a page.

    Hello.

    I am trying to send the resource file information to the page.

    I am using a Store, but on the listener of the store, who call a script on the web page, i can't see the sended information.

    I have that code for the store into the cshtml:

            X
            .Store()
            .ID("dsTranslate")
            .AutoLoad(true)
            .Fields(field =>
                {
                    field.Add("key");
                    field.Add("value");
                }
            )
            .Listeners(lis =>
                    {
                        lis.Load.Fn = "TranslateLoaded";
                    }
                )
            .Proxy(p =>
                {
                    p.Add(
                        X.AjaxProxy()
                        .Url("/extnet/Translate")
                        );
                }
                )
    The controller code for method /extnet/Translate:
            public StoreResult Translate()
            {
    
                var lang = "es-ES";
    
                if (Request.Cookies.Count > 0)
                    lang = Request.Cookies["cultureCode"].Value;
    
    
                CultureInfo cult = Thread.CurrentThread.CurrentCulture;
    
                try
                {
                    cult = new CultureInfo(lang);
                }
                catch (Exception ex) { }
    
                ResourceSet res = Resources.ResourceAdministracion.ResourceManager.GetResourceSet(cult, true, false);
                IDictionaryEnumerator trav = res.GetEnumerator();
                Dictionary<string, string> dict = new Dictionary<string, string>();
    
                while (trav.MoveNext())
                {
                    if (trav.Key.ToString().Length > 2)
                        dict.Add(trav.Key.ToString(), trav.Value.ToString());
                }
    
                var q = from c in dict
                        select new { key = c.Key, value = c.Value };
    
                return new StoreResult(q, dict.Count);
            }
    and the sript where i can't retrive the information sended by the controller store result.
    var TranslateLoaded = function (objGrid, gridRecords, objOptions) {
                for (var i = 0; i < gridRecords.length; i++) {
    
                }
    }
    The object gridRecords have only one Ã*tem, but i send 12 or more into the storeresult.

    Any idea about the problema with the code?
    Need more parameters into the cshtml?


    Edit: Debuging the script, i can see the variable total count with the number of records i have, but i don't know how to get through the entire list.
    Last edited by sishco; Mar 23, 2016 at 9:29 AM.
  2. #2
    Hello, the script snippets do not shed any light to what could be your problem as far as I can realize, at least.

    What you need is a grid with local paging and remote data? A grid with remote paging and remote data?

    Maybe you are going the wrong direction there, our MVC examples explorer may have a working sample that just fit your needs!

    But if you are willing to let us understand your exact scenario and advise you on how to proceed, I'm afraid we'd require a working sample from you, so we can reproduce and identify why your function is not getting the data as you need it.
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hello Again.

    Now all is working ok.

    Only changed the store proxy:

            X
            .Store()
            .ID("dsTranslate")
            .AutoLoad(true)
            .Fields(field =>
                {
                    field.Add("key");
                    field.Add("value");
                }           
            )
            .Listeners(lis=>lis.Load.Fn="TranslateLoaded")
            .Proxy(p =>
                {
                    p.Add(
                        X.AjaxProxy()
                        .Url("/Shell/Translate")
                        .Reader(
                                reader => reader.Add(X.JsonReader().RootProperty("data").TotalProperty("total").IDProperty("key"))
                               )
                        );
                }
                )
    I recover into Transloaded script the resources file, and i can modify the component text with the correct traduction.

    Regards.
  4. #4
    Glad you could fix the issue! And thanks for sharing the solution you found on your case! We really appreciate it!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] send store data items to directmethod
    By snow_cap in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Sep 29, 2013, 10:07 PM
  2. [CLOSED] [1.3] Send custom data on each request
    By John_Writers in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 04, 2012, 5:13 PM
  3. Going back to Page 1 when store data changes
    By omeszar in forum 1.x Help
    Replies: 2
    Last Post: Jul 29, 2011, 1:58 PM
  4. [CLOSED] Need to extract PagingToolbar store data for page X
    By wisdomchuck in forum 1.x Legacy Premium Help
    Replies: 12
    Last Post: Jul 21, 2011, 7:16 PM
  5. How to store the data in Calendar Page
    By krishna in forum 1.x Help
    Replies: 0
    Last Post: Jan 07, 2011, 1:00 PM

Tags for this Thread

Posting Permissions