Results 1 to 2 of 2

Thread: How to implement Create method (CRUD on .NET)

  1. #1
    Sencha User
    Join Date
    Dec 2009
    Gdansk, Poland
    Vote Rating

    Default How to implement Create method (CRUD on .NET)

    I have a store that has been configured like below:
    var recordFields = [ 
                {name:'SortOrder',  type:'int'}, 
                {name:'ExtSysID',   type:'int'}, 
                {name:'Valid',      type:'boolean'}
            var reader = new{
                idProperty      : 'ElementID',
                root            : 'Result',
                totalProperty   : 'TotalCount',
                fields          : recordFields
            var writer = new{
                writeAllFields  : true,
                encode          : false
            var proxy = new{
                    api : {
                        read    : DictionaryElemService.Read,
                        create  : DictionaryElemService.Create,
                        update  : DictionaryElemService.Update,
                        destroy : DictionaryElemService.Destroy
                    paramOrder      : ['start', 'limit', 'sort', 'dir', 'filter', 'parentID'],
                    paramsAsHash    : true
            var store = new{
                autoLoad        : false,
                autoSave        : false,
                reader          : reader,
                writer          : writer,
                proxy           : proxy,
                baseParams      : { start: 0, limit: 50, sort: 'SortOrder', dir: 'ASC', filter: null, parentID:null },
                remoteSort      : true,
                sortInfo        : { field: 'SortOrder', direction: 'ASC'},
                listeners       : {
                    exception : function () {
    I have created a new row by inserting it directly using insert() method. It has some id like 'ext-something'. When I do save operation on the store I see such value passed for the request in the POST body (there are no "id" parameters here at all !):
    This is a body of the "Create" method on server side (.NET Framework):
            public DictionaryElemData Create(JObject paramsAll)
                int i = 0;
                return new DictionaryElemData();
    I can't change the type of input parameter to any my own custom type like"DictionaryElemData" with all the properties embedded inside like in the record layout on client side...

    Does anybody know where is any sample how to do it. I can't find any sample using google !
    I read some chapter in EXT.JS in Action about using DataWriter, but in my case it doesn't send any IDs at all !!!. I see parameters for read operation also here like parentID, where on book samples there were list of Ids and data objects. Why it's so weak documented and I have to spend a lot of time looking for workarounds


  2. #2
    Ext User
    Join Date
    Feb 2010
    Vote Rating



    You need to create a class in .NET that models your input data from direct. Once you have a class that models this data, direct.NET will automaticlly deserialize the data for you and hydrate your object.

    for example

    public class AlexResult
    public int start {get; set;}
    public int limit {get; set;}
    public string sort {get; set;}
    ...Add your other fields in...

    Then your Create method will look like this

    [DirectMethod] public ActionReponse Create(AlexResult data) { //do stuff return this.Direct(response); }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts