1. #101
    Sencha User
    Join Date
    Dec 2007
    Posts
    17
    Vote Rating
    0
    aritchie is on a distinguished road

      0  

    Default


    You are returning "Success" not "success". It is a case sensitive check

  2. #102
    Ext User
    Join Date
    Aug 2009
    Posts
    78
    Vote Rating
    0
    isit.gd is on a distinguished road

      0  

    Default


    Sometimes i add a new method which returns
    Code:
    Direct
    in a controiller which inherits from
    Code:
    DirectController
    and the api at DriectApi.ashx never updates?

    is there something i should be doing?

    i've restarted the web and all that.

    very good implementation however - i'm a big fan.

    w://

  3. #103
    Ext User
    Join Date
    Aug 2009
    Posts
    6
    Vote Rating
    0
    maxigroovy is on a distinguished road

      0  

    Default Array Handling

    Array Handling


    Great tool.
    I got it working with the LiveGrid store (based the Bufferstore on the DirectStore).

    I wanted to save changed value in the store through a JsonWriter to the update api of the directstore (bufferedstore).
    When I saved 1 item, everything was okay. But when I wanted to save more than one changed record from the store I got an array.
    JArray was not supported.

    I made an implementation but I'm really not sure if it is up to your standard, for me it works in my proof of concept. But it's not yet in production state. So if anyone has any comments, improvements or what ever, feel free.

    I created a .patch file (with usage of subversion) against the 0.6.4 version.

    Code:
    Index: DirectMethodInvoker.cs
    ===================================================================
    --- DirectMethodInvoker.cs	(revision 4)
    +++ DirectMethodInvoker.cs	(working copy)
    @@ -1,6 +1,7 @@
     ´╗┐using System;
     using System.Collections.Generic;
     using System.Globalization;
    +using System.Reflection;
     using System.Web.Mvc;
     using Newtonsoft.Json;
     using Newtonsoft.Json.Linq;
    @@ -23,10 +24,33 @@
                         string key = parameterDescriptors[i].ParameterName;
                         object rawValue = data[i];
     
    -                    if (rawValue is JObject && parameterDescriptors[i].ParameterType != typeof(JObject)) {
    -                        rawValue = JsonConvert.DeserializeObject(rawValue.ToString(), parameterDescriptors[i].ParameterType);
    +                    if (rawValue is List<object> && parameterDescriptors[i].ParameterType.BaseType == typeof(Array)) 
    +                    {
    +                        List<object> tempRawArray = rawValue as List<object>;
    +                        for( int j = 0; j < tempRawArray.Count; j++)
    +                        {
    +                            //If is array then get the type of the non array type    
    +                            if (tempRawArray[j] is JObject && parameterDescriptors[i].ParameterType != typeof(JObject)) 
    +                            {
    +                                Assembly assembly = Assembly.GetAssembly(parameterDescriptors[i].ParameterType);                                
    +                                Type type = assembly.GetType(parameterDescriptors[i].ParameterType.FullName.Replace("[]",""));
    +                                tempRawArray[j] = JsonConvert.DeserializeObject(tempRawArray[j].ToString(), type);
    +                            }
    +                        }
    +                        rawValue = tempRawArray.ToArray();
                         }
    +                    else if (rawValue is JObject && parameterDescriptors[i].ParameterType != typeof(JObject)) 
    +                    {
    +                        Type type = parameterDescriptors[i].ParameterType;
    +                        if (type.BaseType == typeof(Array))
    +                        {
    +                            Assembly assembly = Assembly.GetAssembly(type);
    +                            type = assembly.GetType(parameterDescriptors[i].ParameterType.FullName.Replace("[]",""));
    +                        }
    +                        rawValue = JsonConvert.DeserializeObject(rawValue.ToString(), type);
    +                    }
     
    +
                         string attemptedValue = Convert.ToString(rawValue, invariantCulture);
                         valueProvider.Add(key, new ValueProviderResult(rawValue, attemptedValue, invariantCulture));
                     }
    Index: RequestDataConverter.cs
    ===================================================================
    --- RequestDataConverter.cs	(revision 4)
    +++ RequestDataConverter.cs	(working copy)
    @@ -13,12 +13,34 @@
     
                 if (!dataArray.HasValues) return null;
     
    -            foreach (JToken dataItem in dataArray) {
    -                if (dataItem is JObject) {
    +            foreach (JToken dataItem in dataArray) 
    +            {
    +                if (dataItem is JObject) 
    +                {
                         data.Add(dataItem);
    -                } else if (dataItem is JValue) {
    +                } 
    +                else if (dataItem is JValue) 
    +                {
                         data.Add((dataItem as JValue).Value);
    -                } else {
    +                } 
    +                else if (dataItem is JArray) 
    +                {
    +                    List<object> listObjects = new List<object>();
    +                    foreach (JToken arrayDataItem in (dataItem as JArray))
    +                    {
    +                        if (arrayDataItem is JObject) 
    +                        {
    +                            listObjects.Add(arrayDataItem);
    +                        } 
    +                        else if (arrayDataItem is JValue) 
    +                        {
    +                            listObjects.Add((arrayDataItem as JValue).Value);
    +                        } 
    +                    }
    +                    data.Add(listObjects);
    +                }
    +                else 
    +                {
                         throw new ArgumentException("Arguments of this type are not supported.");
                     }
                 }
    Now I can have an update action like this, supporting arrays.
    Code:
            [Authorize]
    		[AcceptVerbs(HttpVerbs.Post)]
    		public ActionResult Update(int[] ids, WebModelContainerStatus[] records)
    		{
    			if (Request.IsAjaxRequest())
    			{

  4. #104
    Ext User
    Join Date
    Aug 2009
    Posts
    6
    Vote Rating
    0
    maxigroovy is on a distinguished road

      0  

    Default


    I've got a question.
    How to return if the update/ create / etc succeeded or failed?

    I tried (in the action-method of the controller):
    Code:
                    var result = new {
                        success = false
                    };
                    return Direct(result);
    But don't know how to handle the response in ExtJs.

  5. #105
    Sencha User
    Join Date
    Jan 2008
    Location
    Toronto, Canada
    Posts
    480
    Vote Rating
    4
    elishnevsky is on a distinguished road

      0  

    Default


    Quote Originally Posted by isit.gd View Post
    Sometimes i add a new method which returns
    Code:
    Direct
    in a controiller which inherits from
    Code:
    DirectController
    and the api at DriectApi.ashx never updates?

    is there something i should be doing?

    i've restarted the web and all that.

    very good implementation however - i'm a big fan.

    w://
    Make sure your method on the server is a true controller action, i.e. its return type is ActionResult, otherwise the API generator will not pick it up. Can't think of another reason. Post your controller code here, I'll take a look.

  6. #106
    Sencha User
    Join Date
    Jan 2008
    Location
    Toronto, Canada
    Posts
    480
    Vote Rating
    4
    elishnevsky is on a distinguished road

      0  

    Default


    maxigroovy

    1. I'll take a look at how you implemented arrays later, too busy right now. But thanks!

    2. With regard to your second comment, I honestly don't know I've never had to do anything like this. Anyhow, it's not directly related to my implementation of Ext.Direct, so you might want to start a new thread in the general Ext.Direct forums.

  7. #107
    Ext User
    Join Date
    Aug 2009
    Posts
    6
    Vote Rating
    0
    maxigroovy is on a distinguished road

      0  

    Default


    And ofcourse it's better to use:

    Code:
    Type type = parameterDescriptors[i].ParameterType.GetElementType();
    instead of the string replacement thing:
    Code:
    Assembly assembly = Assembly.GetAssembly(parameterDescriptors[i].ParameterType);                                
     Type type = assembly.GetType(parameterDescriptors[i].ParameterType.FullName.Replace("[]",""));
    For handling the serialization of arrays.

  8. #108
    Ext User
    Join Date
    Aug 2009
    Posts
    78
    Vote Rating
    0
    isit.gd is on a distinguished road

      0  

    Default


    i really need to figure out how to do this - can anyone help?




    Quote Originally Posted by isit.gd View Post
    Hi

    I want to be able to send down method names as properties on objects - i basically want to send an object which is the colmodel. each of the colmodel items has a renderer method in it:

    Code:
    {header: 'Name', dataIndex: 'Name', sortable: true, renderer: renderers.defaultRenderer }
    i omit the quotes to send it as an object using a JsonConverter:

    Code:
    public class JavascriptMethodConverter : JsonConverter 
        {
            public override bool CanConvert(Type objectType)
            {
                return true;
            }
    
            public override object ReadJson(JsonReader reader, Type objectType, JsonSerializer serializer)
            {
                throw new NotImplementedException();
            }
    
            public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
            {
                writer.WriteRaw((string)value);
            }
        }
    which gets added to the c# property like:

    Code:
      [JsonConverter(typeof(JavascriptMethodConverter))]
      public virtual string Renderer { get; set; }
    i keep getting an error saying it would result in invalid js whenever this is included.

    this seems like a standard use case to me - is there anything i'm doing wrong?

    cheers

    w://

  9. #109
    Ext User
    Join Date
    Sep 2008
    Posts
    7
    Vote Rating
    0
    kriz is on a distinguished road

      0  

    Default


    Can someone make a rs mirror?I can't download this file.Thks.

  10. #110
    Ext User
    Join Date
    Aug 2009
    Posts
    4
    Vote Rating
    0
    Ankai is on a distinguished road

      0  

    Default ASP.NET MVC with Polling

    ASP.NET MVC with Polling


    Hi!
    At first, thanks for your work!

    I need some advice or sample of using your implementation with polling provider, of course if you already have something specially for this? Now I'm creating new polling provider and it repetitively makes post requests to the action.