netzke / netzke-core

Framework for Sencha Ext JS + Ruby on Rails client-server components
http://netzke.org
Other
263 stars 77 forks source link

can't use Ext.form.panel with directSubmit type to directly communicate with endpoint #67

Closed comme closed 8 years ago

comme commented 11 years ago

when i use Ext.form.panel set config:

Ext.create('Ext.form.Panel', {
        //some configure
        api: {
          submit: Netzke.providers[_this.id].search
        },
        buttons: [{
          {
          text: 'Search',
          handler: function() {
            var form = this.up('form').getForm();
            if (form.isValid()) {
              form.submit({
                params: {name: 'aaa'},
              });
            }
          }
        }],
       //some configure

i hope it send request with params: "name" => "aaa", but i get this:{"path":"applicationtp_panel__requirements_managementrequirements_tree","endpoint":"search","data":[undefined],"tid":3} so i review code,i found in (extjs api)[http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.Basic] config options api say: The formHandler configuration (see Ext.direct.RemotingProvider#action) must be set on the associated server-side method which has been imported by Ext.direct.Manager. but netzke doesn't provide support to set endpoint formHandler true, in https://github.com/netzke/netzke-core/blob/ext42/javascripts/ext.js#L82-L91

  addEndpointsForComponent: function(componentPath, componentId, endpoints) {
    var cls = this.namespace[componentId] || (this.namespace[componentId] = {});

    Ext.Array.each(endpoints, function(ep) {
      var methodName = ep.camelize(true),
           //some endpoint should have config["formHandler"] = true
          method = Ext.create('Ext.direct.RemotingMethod', {name: methodName, len: 1});

        cls[methodName] = this.createHandler(componentPath, method);
    }, this);
  },
mxgrn commented 8 years ago

Netzke direct providers are meant to work with Netzke components only. Why not use Netzke::Basepack::Form?

Please, reopen if still relevant, closing for now.