1. #351
    Sencha User
    Join Date
    Jul 2010
    Posts
    6
    Vote Rating
    0
    ashkan is on a distinguished road

      0  

    Default problem on proxy desroy api

    problem on proxy desroy api


    hi all

    i am new on extjs . i have a problem on ext.direct for asp.net mvc 3

    here is my codes:

    thos is my model:
    Code:
    Ext.define('Crm.model.Storage', {
        extend: 'Ext.data.Model',
        idProperty: 'Id',
        fields: [
            { name: 'Id', type: 'int' },
            { name: 'CustomCode', type: 'string' },
            { name: 'Name', type: 'string' },
            { name: 'IsDefault', type: 'boolean' }
        ]
    });
    this is my store :

    Code:
    Ext.define('Crm.store.Storages', {
        extend: 'Ext.data.Store',
        model: 'Crm.model.Storage',
        pageSize: 10,
        autoLoad: true,
        autoSync: false,
        autoDestroy: true,
        proxy: {
            type: 'direct',
            //directFn: Storage.List,
            paramOrder: 'start|limit',
            api: {
                create: Storage.New,
                read: Storage.List,
                update: Storage.Update,
                destroy: Storage.DeleteStorage
            },
            reader: {
                type: 'json',
                root: 'data'
            },
            writer: {
                type: 'json',
                root: 'data',
                encode: true,
                writeAllFields: true
            }
        }
    });
    this is my app :
    Code:
    Ext.Loader.setConfig({
        enabled: true,
        paths: { 'Crm': '/app' }
    });
    
    
    Ext.require([
        'Crm.model.Storage',
        'Crm.store.Storages',
        'Crm.view.StorageGrid',
        'Crm.view.StorageForm',
        'Ext.ux.plugins.FitToParent'
    ]);
    
    
    Ext.direct.Manager.addProvider(Ext.app.REMOTING_API);
    
    
    Ext.application({
        name: 'Crm',
    
    
        models: ['Storage'],
        stores: ['Storages'],
    
    
        launch: function () {
    
    
            var newAction = Ext.create('Ext.Action', {
                text: 'انبار جدید',
                disabled: false,
                handler: function (widget, event) {
                    var record = Ext.create('Crm.model.Storage');
                    gridStorages.store.insert(0, record);
                }
            });
    
    
            var deleteAction = Ext.create('Ext.Action', {
                text: 'حذف انبار',
                disabled: true,
                handler: function (widget, event) {
    
    
                    var sm = gridStorages.getSelectionModel();
    
    
                    gridStorages.store.remove(sm.getSelection()[0]);
    
    
                    gridStorages.store.sync();
    
    
                }
            });
    
    
            var formStorage = Ext.create('Crm.view.StorageForm', {
                columnWidth: 0.30,
                width: 350,
                height: 550
            });
    
    
            var gridStorages = Ext.create('Crm.view.StorageGrid', {
                columnWidth: 0.70,
                autoHeight: true,
                height: 550,
                tbar: ['->', newAction, deleteAction],
                listeners: {
                    selectionchange: function (model, records) {
                        if (records[0]) {
                            formStorage.loadRecord(records[0]);
                            deleteAction.enable(true);
                        }
                    }
                }
            });
    
    
            var panelStorages = Ext.create('Ext.panel.Panel', {
                title: 'مدیریت انبارها',
                plugins: ['fittoparent'],
                layout: {
                    type: 'column'
                },
                items: [gridStorages, formStorage],
                renderTo: 'gridCt'
            });
        }
    });
    and finally it is my controller in asp.net mvc :

    Code:
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Linq;
    using System.Text;
    using System.Web;
    using System.Web.Mvc;
    using CrmMvc.Models;
    using DataAccess;
    using Ext.Direct.Mvc;
    using Model;
    using Newtonsoft.Json;
    using Service;
    using StructureMap;
    
    
    namespace CrmMvc.Controllers
    {
        public class StorageController : DirectController
        {
            private readonly Context _db = new Context();
    
    
            public ActionResult List(int start, int limit)
            {
                var total = _db.Storages.Count();
    
    
                var storages = _db.Storages.OrderBy(s => s.Id).ThenBy(s => s.CustomCode).Skip(start).Take(limit).ToList();
    
    
                return Json(new
                {
                    total = total,
                    data = storages
                }, "json", Encoding.UTF8, JsonRequestBehavior.AllowGet, new JsonSerializerSettings()
                {
                    ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                });
            }
    
    
    
    
            [FormHandler]
            [ActionName("SaveStorage")] // Action alias
            public ActionResult SaveStorage(Storage storage)
            {
    
    
                string msg = String.Empty;
    
    
                if (storage.Id == 0)
                {
                    _db.Entry(storage).State = EntityState.Added;
                    msg = "Saved.";
                }
                else
                {
                    _db.Entry(storage).State = EntityState.Modified;
                    msg = "Updated.";
                }
                _db.SaveChanges();
    
    
                return Json(new
                                {
                                    success = true,
                                    data = storage,
                                    message = msg
                                });
            }
    
    
            [ActionName("DeleteStorage")]
            public DirectResult DeleteStorage(int id)
            {
                string msg = String.Empty;
    
    
                Storage storage = _db.Storages.Find(id);
                _db.Storages.Remove(storage);
                _db.SaveChanges();
    
    
                msg = "Deleted.";
    
    
                return Json(new
                {
                    success = true,
                    data = id,
                    message = msg
                });
            }
    
    
            protected override void Dispose(bool disposing)
            {
                _db.Dispose();
                base.Dispose(disposing);
            }
    
    
        }
    }
    the grid is loading all storages but when the user selects one row on grid then press delete button on grid toolbar this exception raised :

    The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'Ext.Direct.Mvc.DirectResult DeleteStorage(Int32)' in 'CrmMvc.Controllers.StorageController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
    Parameter name: parameters.
    what can i do?

    thnaks for your helps.

  2. #352
    Touch Premium Member
    Join Date
    Nov 2011
    Posts
    124
    Vote Rating
    0
    JavascriptParrot is on a distinguished road

      0  

    Default


    Hello,

    Anybody know how to silence the unhandled exception popup in Visual Studio?

    Thanks

  3. #353
    Sencha User
    Join Date
    Feb 2012
    Location
    Davenport, IA
    Posts
    30
    Vote Rating
    6
    WillFM is on a distinguished road

      0  

    Default


    I searched through the thread a bit and didn't see anything posted about this.

    When I make a controller actions, with overloads, "directapi", won't make references to that controller.

    Why is that?

  4. #354
    Ext JS Premium Member
    Join Date
    May 2008
    Posts
    372
    Vote Rating
    4
    ttbgwt is on a distinguished road

      0  

    Default


    Does this work with Visual Studio 2012?

  5. #355
    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 ttbgwt View Post
    Does this work with Visual Studio 2012?
    I don't see why it shouldn't.

  6. #356
    Ext JS Premium Member
    Join Date
    May 2008
    Posts
    372
    Vote Rating
    4
    ttbgwt is on a distinguished road

      0  

    Default


    Have you tested with MVC 4 yet?

  7. #357
    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 ttbgwt View Post
    Have you tested with MVC 4 yet?
    Yes. It works fine.

  8. #358
    Ext JS Premium Member
    Join Date
    May 2008
    Posts
    372
    Vote Rating
    4
    ttbgwt is on a distinguished road

      0  

    Default


    I just downloaded Visual Studio 2012, and was able to run your test project no problems. It migrated with minor warnings

    Quote Originally Posted by elishnevsky View Post
    I don't see why it shouldn't.

  9. #359
    Ext JS Premium Member
    Join Date
    May 2008
    Posts
    372
    Vote Rating
    4
    ttbgwt is on a distinguished road

      0  

    Default


    Can you please compile a version with MVC 4 and post on your site?

    http://code.google.com/p/ext-direct-mvc/downloads/list

    Quote Originally Posted by elishnevsky View Post
    Yes. It works fine.

  10. #360
    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 ttbgwt View Post
    Can you please compile a version with MVC 4 and post on your site?

    http://code.google.com/p/ext-direct-mvc/downloads/list
    Here you are, try it:
    http://ext-direct-mvc.googlecode.com...t-mvc4-bin.zip

    Reference the Json.NET from the archive as well.

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi