1. #1
    Ext User
    Join Date
    Apr 2008
    Posts
    10
    Vote Rating
    0
    bas_denis is on a distinguished road

      0  

    Default [3.0 RC1] DirectStore

    [3.0 RC1] DirectStore


    any working DirectStore example?

    me don't get it,
    help appreciated (if using svn version plz mention)
    backend and Provider is not needed / not in detail, those are working fine
    (used Ext.Direct Example and added a getData method which gives some Array of Objects Result)

    kind regards

    my try:

    post:
    Code:
    {"action":"TestAction","method":"getData","data":null,"type":"rpc","tid":2}
    response:
    Code:
    {"type":"rpc","tid":2,"action":"TestAction","method":"getData",
    "result":[
    {"id":1,"value":"Value 1"},
    {"id":2,"value":"Value 1"},
    {"id":3,"value":"Value 2"}
    ]}
    testcase:
    Code:
    Ext.onReady(function()
    {
    	Ext.Direct.addProvider({
    		url : "php/router.php",
    		type : "remoting",
    		id : 'remote-provider',
    		actions : {
    			TestAction : [
    				{
    					name : "getData",
    					len : 0
    				}
    			]
    		}
    	});
    	
    	var getData = new Ext.Button({
    		text : 'getData',
    		handler : function()
    		{
    			TestAction.getData(function(result, e)
    			{
    				console.debug(result)
    			});
    		}
    	});
    	
    	var store = new Ext.data.DirectStore({
    		autoLoad : true,
    		// directFn isn't recognized by proxy, used api:load instead
    		api : {
    			load : TestAction.getData
    		},
    		root : 'result',
    		paramsAsHash : false,
    		fields : [
    			'id',
    			'value'
    		],
    		listeners : {
    			load : function()
    			{
    				console.info('load', this, arguments)
    			},
    			loadexception : function()
    			{
    				console.warn('loadexception', this, arguments)
    			},
    			scope : this
    		}
    	});
    	
    	var grid = new Ext.grid.GridPanel({
    		store : store,
    		columns : [
    			{
    				id : 'id',
    				header : 'id',
    				width : 200,
    				dataIndex : 'id'
    			},
    			{
    				header : 'value',
    				width : 120,
    				dataIndex : 'value'
    			}
    		],
    		viewConfig : {
    			forceFit : true
    		},
    		sm : new Ext.grid.RowSelectionModel({
    			singleSelect : true
    		})
    	});
    	
    	var p = new Ext.Panel({
    		title : 'Remote Call Grid',
    		width : 600,
    		height : 300,
    		layout : 'fit',
    		items : [
    			grid
    		],
    		bbar : [
    			getData
    		]
    	}).render(Ext.getBody());
    	
    });
    added bugnote: [3.0 RC1] Ext.data.DirectProxy incomplete ?
    Last edited by bas_denis; 18 Apr 2009 at 1:17 AM. Reason: Added Bugnote

  2. #2
    Ext User
    Join Date
    Apr 2008
    Posts
    10
    Vote Rating
    0
    bas_denis is on a distinguished road

      0  

    Exclamation


    for sure DirectProxy seems incomplete.

    not using the directFn on store config,
    instead using api.load, causes DirectProxy.doRequest to add the params ({xaction:'load'}) as a first argument,
    so it mismatches the Provider methods arguments and with it the arguments callback position

    as a unpretty workaround for the above code it should do setting the Providers method arguments len to 1 and removing the root property

    if DirectProxy working as intended, it may look something like this: (for the above code)
    Code:
    [ ... ]
    	var store = new Ext.data.DirectStore({
    		autoLoad : true,
    		directFn : TestAction.getData,
    		//root : 'result',
    		fields : [
    			'id',
    			'value'
    		]
    	});
    [ ... ]

  3. #3
    Ext JS Premium Member Artistan's Avatar
    Join Date
    Apr 2007
    Location
    MN
    Posts
    144
    Vote Rating
    0
    Artistan is on a distinguished road

      0  

    Default


    I am trying the directFn and it is adding 'xaction' => 'load' to the 'data' passed.
    POST
    Code:
    {"action":"ExtDirect_Tickets","method":"get","data":["id","ASC","1","10"],"type":"rpc","tid":2}
    How do I get it to load without that, and pass parameters to the function?

    UPDATE::
    when I added baseParams, paramsNames it works,
    but that locks it down the the baseParams.


    Code:
     
    Ext.ns('Ext.BENINT'); Ext.BENINT.APIDesc = {"url":"router\/","type":"remoting","actions":{"ExtDirect_Tickets":[{"name":"get","len":2},{"name":"add","len":2,"formHandler":true},{"name":"save","len":2,"formHandler":true},{"name":"delete","len":2,"formHandler":true},{"name":"list","len":1,"serverMethod":"example"},{"name":"doEcho","len":1},{"name":"multiply","len":1}]},"namespace":"Ext.BENINT"};

    Code:
     
    
        var store = new Ext.data.DirectStore({
            api: {
                load: Ext.BENINT.ExtDirect_Tickets.get,
                create: Ext.BENINT.ExtDirect_Tickets.add,
                save: Ext.BENINT.ExtDirect_Tickets.save,
                destroy: Ext.BENINT.ExtDirect_Tickets.delete
            },
            paramOrder: ['sort','dir','start','limit'],
            autoLoad : true,
            storeId:'open-tickets',
            root: 'list',
            paramsNames: {
                start : "start",  // The parameter name which specifies the start row
                limit : "limit",  // The parameter name which specifies number of rows to return
                sort : "sort",    // The parameter name which specifies the column to sort on
                dir : "dir"       // The parameter name which specifies the sort direction
            },
            remoteSort: true,
            baseParams: {
                start : "1",
                limit : "10",
                sort : "id",
                dir : "ASC"
            },
            idProperty: 'id',
            fields: [
                {
                    name: 'id',
                    type: 'int'
                },
                'value'
            ],
            listeners : {
                load : function()
                {
                    console.info('load', this, arguments)
                },
                loadexception : function()
                {
                    console.warn('loadexception', this, arguments)
                },
                update : function()
                {
                    /*
                    this.commitChanges
                    Commit all Records with outstanding changes.
                    To handle updates for changes, subscribe to the Store's update event,
                    and perform updating when the third parameter is Ext.data.Record.COMMIT.
                    */
                    console.warn('loadexception', this, arguments)
                },
                scope : this
            }
            /*baseParams*/
            /*writer*/
        });
    
        // create the Grid
        var grid = new Ext.grid.EditorGridPanel({
            store: store,
            colModel: new Ext.grid.ColumnModel({
                columns: [
                    {id:'ticket_id', header: "ID", width: 30, dataIndex: 'id'},
                    {id:'ticket_value', header: "Value", dataIndex: 'value'}
                    /*{header: "Change", renderer: change, dataIndex: 'change'}*/
                ],
                defaults: {
                    sortable: true,
                    width: 75
                }
            }),
            autoExpandColumn: 'ticket_value', // match the id specified in the column model
            height:350,
            width:600,
            /*title:'Array Grid',*/
            tbar: [{
                text: 'Add Record',
                handler : function(){
                    /*****************
                    Need to find how to add to db
                    *****************/
                    var defaultData = {
                        id: '-',
                        value: '1'
                    };
                    var recId = 3; // provide unique id
                    var p = new store.recordType(defaultData, recId); // create new record
                    grid.stopEditing();
                    store.insert(0, p); // add new record to the store
                    grid.startEditing(0, 0);
                }
            }]
        });
    
        var p = new Ext.Panel({
            title : 'Remote Call Grid',
            width : 600,
            height : 300,
            layout : 'fit',
            items : [
                grid
            ],
            bbar : [
                getData
            ]
        }).render(Ext.getBody());
    Response
    Code:
    {"type":"rpc","tid":2,"action":"ExtDirect_Tickets","method":"get","result":{"list":[{"id":1,"value":"'id'"
    },{"id":2,"value":"foo"},{"id":3,"value":"foo"},{"id":4,"value":"foo"},{"id":5,"value":"foo"},{"id":6
    ,"value":"foo"},{"id":7,"value":"foo"}],"count":7}}

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar