1. #291
    Ext User
    Join Date
    Jan 2010
    Posts
    3
    Vote Rating
    0
    daemon110282 is on a distinguished road

      0  

    Default


    hi

    do you have an example usign asp.net mvc model data validation in extjs?

  2. #292
    Ext JS Premium Member
    Join Date
    May 2008
    Posts
    374
    Vote Rating
    13
    ttbgwt will become famous soon enough

      0  

    Default


    In your EmployeesController code you return a list of Employees:

    Code:
        public class EmployeesController : Controller {
    
            readonly SampleDataContext _db = new SampleDataContext();
    
            public ActionResult Get(int start, int limit, string sort, string dir) {
                var employeeList = _db.Employees
                    .OrderBy(sort + " " + dir)
                    .Skip(start)
                    .Take(limit);
    
                var result = new {
                    total = _db.Employees.Count(),
                    data = employeeList
                };
    
                return this.Direct(result);
            }
        }
    How can I get this to GroupBy the employee's Gender and to return data so it can be used by a TreePanel? It needs to return tree node data such as:

    id = <gender id>,
    text = <gender name>,
    leaf = <true if Gender, false if person>,
    @checked = false,
    children = <persons grouped by gender

  3. #293
    Ext JS Premium Member
    Join Date
    May 2008
    Posts
    374
    Vote Rating
    13
    ttbgwt will become famous soon enough

      0  

    Default


    I figured it out.
    Code:
            public ActionResult GetPumpsTree()
            {
                var pumpList = _db.Pump_Datas
                    .GroupBy(pump => pump.Pump_Series, pump => pump.Pump_Description)
                    .Select(g => new
                    {
                        Series = g.Key,
                        Descriptions = g.ToList()
                    })
                    .OrderByDescending(t => t.Series)
                    //.Take(25)
                    .ToList();
    
                var seriesArray = new ArrayList();
                foreach (var pumpSeries in pumpList)
                {
                    var descriptionArray = new ArrayList();
                    foreach (var pumpDescription in pumpSeries.Descriptions)
                    {
                        descriptionArray.Add(new
                        {
                            id = pumpDescription,
                            text = pumpDescription,
                            leaf = true,
                            uiProvider = "tristate",
                            @checked = true
                        });
                    }
    
                    seriesArray.Add(new
                    {
                        id = pumpSeries.Series,
                        text = pumpSeries.Series,
                        leaf = false,
                        uiProvider = "tristate",
                        @checked = true,
                        children = descriptionArray.ToArray()
                    });
                }
    
                var allPumpsArray = new ArrayList();
                allPumpsArray.Add(new
                {
                    id = "root",
                    text = "All Pumps",
                    leaf = false,
                    uiProvider = "tristate",
                    @checked = true,
                    children = seriesArray.ToArray()
                });
    
                return this.Direct(allPumpsArray.ToArray());
            }

  4. #294
    Ext JS Premium Member
    Join Date
    May 2008
    Posts
    374
    Vote Rating
    13
    ttbgwt will become famous soon enough

      0  

    Default


    How can I get the result portion of the direct call to update the tree node? I think think the tree is only expecting the "result" portion?

    Code:
    {
      "type": "rpc",
      "tid": 2,
      "action": "Test",
      "method": "GetPumpsTree",
      "result": [
        {
          "id": "12D",
          "text": "12D",
          "leaf": false,
          "iconCls": "pump-series",
          "uiProvider": "tristate",
          "checked": true,
          "expanded": false,
    Code:
    			loader: new Ext.tree.TreeLoader({
    				preloadChildren: false,
    				directFn: Test.GetPumpsTree,
    				uiProviders: { tristate: Ext.tree.TreeNodeTriStateUI }
    			}),

  5. #295
    Ext JS Premium Member
    Join Date
    Apr 2010
    Posts
    20
    Vote Rating
    0
    nikolawannabe is on a distinguished road

      0  

    Default


    Is there any reason I should assume that Ext.Direct for MVC won't currently work with MVC3 RC2?

    My application was originally built using Ext.Direct and MVC1. I'm prototyping and planning for next release, and am upgrading MVC to get the Razor templating language, but I'm having issues, and don't see any documentation stating whether or not it is expected to work with MVC3.

    I've downloaded the most recent binaries that state they were compiled with VS2010 and included them in my project. It compiles fine but it is trying to access the api as a web page (:3151/Direct/ApiFailed to load resource: the server responded with a status of 404 (Not Found)).

    Thanks!

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

      0  

    Default


    I haven't even tried building it against MVC 3 yet. Maybe I'll do that when I get free time.

  7. #297
    Ext JS Premium Member
    Join Date
    Apr 2010
    Posts
    20
    Vote Rating
    0
    nikolawannabe is on a distinguished road

      0  

    Default


    Quote Originally Posted by elishnevsky View Post
    I haven't even tried building it against MVC 3 yet. Maybe I'll do that when I get free time.
    I just compiled your source against the MVC3 RC2 dll and the Newtonsoft library that ships with it. After upgrading the demo to MVC3, it seems to work fine.

    When I try execute requests against the newly recompiled library on mine though, I get an error:
    Method 'ReadJson' in type 'Ext.Direct.Mvc.RequestDataConverter' from assembly 'Ext.Direct.Mvc, Version=3.0.0.35856, Culture=neutral, PublicKeyToken=2ec707a789ea209b' does not have an implementation.
    I figure this ought to be something simple since yours works fine but I've been digging for a while and haven't figured it out. Let me know if you have any ideas. Thanks again.

  8. #298
    Ext JS Premium Member
    Join Date
    Apr 2010
    Posts
    20
    Vote Rating
    0
    nikolawannabe is on a distinguished road

      0  

    Default


    Quote Originally Posted by nikolawannabe View Post
    I just compiled your source against the MVC3 RC2 dll and the Newtonsoft library that ships with it. After upgrading the demo to MVC3, it seems to work fine.

    When I try execute requests against the newly recompiled library on mine though, I get an error.
    Nevermind, I got it. I was using the wrong Newtonsoft dll. Using the one that ships with Ext.Direct works fine.

  9. #299
    Ext JS Premium Member
    Join Date
    May 2008
    Posts
    374
    Vote Rating
    13
    ttbgwt will become famous soon enough

      0  

    Default


    I want to pass back data and populate my class object, but it's erroring on converting into double[] DriveSpeed. What I actually want to do is pass back driveSpeed0, driveSpeed1, driveSpeed2, driveSpeed3 and have it populate the double[] DriveSpeed.

    Code:
    handler: function () 
    {
        //build the json to send
        var pumpInputs = {
            DriveSpeed: Ext.getCmp('driveSpeed0').getValue()
        }
        
        //send the json
        Test.EchoGuiInputs(guiInputs, function (result, response) { 
             var guiInputs = result.data;
        }
    }
    Code:
    public class GuiInputs
    {
        public double[] DriveSpeed { get; set; }
    }
    Code:
            public ActionResult EchoGuiInputs(GuiInputs guiInputs)
            {
                return this.Direct(new
                {
                    success = true,
                    data = guiInputs
                }, new StringEnumConverter());
            }

  10. #300
    Sencha User
    Join Date
    Jun 2010
    Posts
    47
    Vote Rating
    0
    dan_b is on a distinguished road

      0  

    Default


    Quote Originally Posted by elishnevsky View Post
    I haven't even tried building it against MVC 3 yet. Maybe I'll do that when I get free time.
    Runs fine against MVC3 here.