[CLOSED] Send Json object with get value with loaders

  1. #1

    [CLOSED] Send Json object with get value with loaders

    i have json object and some parameters in js function

    i want to send in my controller action all of variable but json object is always null.
    i use actually my get values with url

    js function
    var json = JSON.stringify(bandeau);
        var newTab = Ext.create("Ext.container.Container", {
            id: idTab,
            renderTo: Ext.getBody(),
            hidden: true,
            layout: 'fit',
            border: false,
            loader: {
                renderer: "frame",
                url: AppPath + "DashBoardGenerator/LoadTable?tableName=" + tableName + "&idProc=" + id + "&clientId=" + clientId + "&currencyId=" + currencyId,
                loadMask: {
                    showMask: true,
                    msg: TIO.Resources.PreparingDisplay
                },
                params:
                {
                    bandeau: json
                }
    
            }
        })

    action controller
            public ActionResult LoadTable(string tableName, int idProc, int clientID, int? currencyId, Headband bandeau)
            {
    
    }
    use parameter value
    private DashBoardExtendedParametersModel GetDashBoardExtendedParametersModelByUrl(Uri url)
            {
                string queryString = (!string.IsNullOrEmpty(url.Query)) ? url.Query.Remove(0, 1) : string.Empty;// supression du ?
                if (!string.IsNullOrEmpty(queryString))
                {
                    Dictionary<string, string> uriParameters = new Dictionary<string, string>();
                    queryString.Split('&').ToList().ForEach(p => uriParameters.Add(p.Split('=')[0], p.Split('=')[1]));
    
                    return new DashBoardExtendedParametersModel
                    {
                        ClientId = int.Parse(uriParameters["clientId"]),
                        CurrencyId = (uriParameters["currencyId"] != "null") ? int.Parse(uriParameters["currencyId"]) : (int?)null,
                        TableName = uriParameters["tableName"],
                        IdProc = int.Parse(uriParameters["idProc"])
                    };
                }
    
    
                return null;
            }
    Regards
    Last edited by Daniil; Oct 07, 2013 at 4:23 PM. Reason: [CLOSED]
  2. #2
    Hi @Tactem,

    I am not sure, but please try to replace:
    params: {
        bandeau: json
    }
    with
    params: json
  3. #3
    Please ignore my previous post.

    I overlooked that you are using
    renderer: "frame"
    An iframe can be loaded via a GET request only. So, the only way to send the parameters is a query string. So, please pass bandeau via a query string as well if it doesn't exceed the size limitation of a GET request.
  4. #4
    thx Daniil

    the good version

    var idTab = "Tab" + tabIndex;
        //DashBoardExtendedParametersModels[idTab] = createDashBoardExtendedParametersModel(tableName, id, clientId, currencyId);
        var json = JSON.stringify(bandeau);
        var newTab = Ext.create("Ext.container.Container", {
            id: idTab,
            renderTo: Ext.getBody(),
            hidden: true,
            layout: 'fit',
            border: false,
            loader: {
    
                renderer: "frame",
                url: AppPath + "DashBoardGenerator/LoadTable?tableName=" + tableName + "&idProc=" + id + "&clientId=" + clientId + "&currencyId=" + currencyId + "&serializedHeadBand=" + encodeURI(json),
                loadMask: {
                    showMask: true,
                    msg: TIO.Resources.PreparingDisplay
                }
            }
        })
    public ActionResult LoadTable(string tableName, int idProc, int clientID, int? currencyId, string serializedHeadBand)
            {
                Headband headBand = null; 
                try
                {
                    var json = HttpUtility.UrlDecode(serializedHeadBand);
                    headBand = JsonConvert.DeserializeObject<Headband>(json);
                }
                catch { }
    }

Similar Threads

  1. How to give a converted object from an json ?
    By marcelorosait in forum 1.x Help
    Replies: 4
    Last Post: Feb 20, 2012, 12:41 PM
  2. JSON Object to Store
    By Tbaseflug in forum 1.x Help
    Replies: 0
    Last Post: Oct 11, 2011, 9:44 PM
  3. Can Store.DateSource send sub object to client?
    By firebank in forum 1.x Help
    Replies: 2
    Last Post: Apr 15, 2010, 12:48 PM
  4. Send complex object to AjaxMethod
    By glenh in forum 1.x Help
    Replies: 2
    Last Post: Aug 13, 2009, 11:01 AM
  5. Replies: 1
    Last Post: Jul 14, 2008, 8:07 PM

Tags for this Thread

Posting Permissions