[CLOSED] pass json data in the Ajax store proxy

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] pass json data in the Ajax store proxy

    Hi, I have been constantly working on the following issue , with a positivity of finding a solution, but in vain.

    So here is the issue:

    I am trying to find if I can pass a typical json formatted string in the store proxy request body. like I want to implement the following jquery ajax call in the ext.net store proxy

    var Url = "/OperationalControlServices/Service1/data/MuseumComponentDetails";
    var request = $.ajax({
    url: Url,
    type: 'post',
    dataType: 'json',
    contentType: 'application/json; charset=utf-8',
    data: JSON.stringify({ json: jsonString, json2: jsonString2 })
    });
    especially the ext.net mode of implementing the "data:" part in the above jquery is needed for me.


    And the json string will be something like this -


    {"json":"[{"PROJECT_ID":"2","PROJECT_NAME":"ABCD","PROJECT_DESC":"ABCD","PROJECT_STATUS_ID":"1","REMEDIATION_ID":"1","REMEDIATION_DATE":"11/20/2013 12:00:00 AM","DATE_TYPE":"Date","CONTACT_ID":"2","SID":"123456","MUSEUM_LIST":"1,6,14"}]"}
    I have tried to set the root to "json" ( this json is the parameter name as you can find in the above string.), & also tried various possibilities...but no luck...:(

    And finally, here is the Store proxy:

    Ext.Net.Store resultStore = new Ext.Net.Store()
                {
                    AutoLoad = autoLoad,
                    Proxy =
                    {
                        new AjaxProxy()
                        { 
                            Json = true, 
                             
                            ActionMethods = { Read = Ext.Net.HttpMethod.POST, Create = Ext.Net.HttpMethod.POST},
                            Url = proxyUrl,
    
                            Headers = {
                                new Ext.Net.Parameter("Accept", "application/json"),
                                new Ext.Net.Parameter("Content-Type", "application/json")
                               
                              
                            },
                            Reader = { new Ext.Net.JsonReader() { Root = "" } },
                            Writer = { 
                                new Ext.Net.JsonWriter()
                                { 
                                      Root="json", Encode=true // this is what I tried to do..this "json" is the parameter name in the above given json string.
                                } 
                              
    
                            } ,
                         
                        }
                    }
    
                    
                };
    Hoping to get a fix soon ! :)

    Thanks a lot !
    Veda
    Last edited by Daniil; Jul 18, 2013 at 4:27 PM. Reason: Please use [CODE] tags, [CLOSED]
  2. #2
    Hi Veda,

    Welcome to the Ext.NET forums!

    I think you should set up "json" Root for the Reader.
    Reader = { new Ext.Net.JsonReader() { Root = "json" } }
    Does it help?
  3. #3
    how is it going to pass actual json data if i set this?
    Last edited by Sowjanya; Jul 18, 2013 at 5:42 AM.
  4. #4
    Well, it should work with the JSON that you posted:
    {"json":"[{"PROJECT_ID":"2","PROJECT_NAME":"ABCD","PROJECT_DESC":"ABCD","PROJECT_STATUS_ID":"1","REMEDIATION_ID":"1","REMEDIATION_DATE":"11/20/2013  12:00:00  AM","DATE_TYPE":"Date","CONTACT_ID":"2","SID":"123456","MUSEUM_LIST":"1,6,14"}]"}
  5. #5
    Quote Originally Posted by Daniil View Post
    Well, it should work with the JSON that you posted:
    {"json":"[{"PROJECT_ID":"2","PROJECT_NAME":"ABCD","PROJECT_DESC":"ABCD","PROJECT_STATUS_ID":"1","REMEDIATION_ID":"1","REMEDIATION_DATE":"11/20/2013  12:00:00  AM","DATE_TYPE":"Date","CONTACT_ID":"2","SID":"123456","MUSEUM_LIST":"1,6,14"}]"}

    Actually, I am trying to do this - the web page receives the json string as a query string parameter. This json string needs to be passed to restful service.

    And as per your answer, I can not set root="json" because json is just a parameter in the whole json string. Also, i dont think the Reader's root needs to be set with that value because, reader is to read the data passed from web service to the web page( as per my understanding..pls correct me if I ma wrong..)

    I am trying to pass json formatted string in the ajax call to service.

    for e.g,

    string jsonstr = "{"json":"[{"PROJECT_ID":"2","PROJECT_NAME":"ABCD","PROJECT_DESC":"ABCD","PROJECT_STATUS_ID":"1","REMEDIATION_ID":"1","REMEDIATION_DATE":"11/20/2013 12:00:00 AM","DATE_TYPE":"Date","CONTACT_ID":"2","SID":"i340371","MUSEUM_LIST":"1,6,14"}]"}"
    i want to pass jsonstr ( json is a parameter in that string.)

    Thanks again !
    Veda
    Last edited by Daniil; Jul 18, 2013 at 6:28 AM. Reason: Please use [CODE] tags
  6. #6
    Sorry, seems I misunderstood the requirement.

    Yes, a Reader is to read the data for an AjaxProxy's response.

    This json string needs to be passed to restful service.
    That service that you referring in the AjaxProxy's Url, right?
    Url = proxyUrl
    If so, you should use an AjaxProxy's ExtraParams.
    <ext:AjaxProxy>
        <ExtraParams>
            <ext:Parameter Name="paramName" Value="getParamValueFromQueryString()" Mode="Raw" />
        </ExtraParams>
    </ext:AjaxProxy>
    There "getParamValueFromQueryString" is supposed to be a JavaScript function returning a parameter's value.

    However, it might be easier to extract the parameter from a Query string in code behind and put it to the AjaxProxy's ExtraParams in code behind as well.
    Last edited by Daniil; Jul 18, 2013 at 6:38 AM.

Similar Threads

  1. [CLOSED] disable the loading mask on ajax proxy store load
    By RCM in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Jan 13, 2015, 4:54 PM
  2. Replies: 1
    Last Post: Jun 18, 2013, 3:56 PM
  3. Replies: 9
    Last Post: Oct 16, 2012, 12:05 AM
  4. [CLOSED] Load data to store of combobox by proxy
    By ViDom in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Oct 08, 2012, 8:29 AM
  5. Replies: 13
    Last Post: Sep 07, 2012, 6:23 PM

Tags for this Thread

Posting Permissions