user3045654
user3045654

Reputation: 1734

Change URL to send to the server

I have a component and when enter to the component text, then on server go query and in component output matching information in grid view. But I have problem i am need send to server URL in this format:

/book/list?filter=[{"field":"Name","type":"string","value":"query"}]

but now i am send in this format:

/book/list?filter=field=Name&type=string&value=kn&query=kn&

this component:

xtype: 'gridpicker',
                        store: {
                            fields: [
                                {name: 'id', type: 'int'},
                                {name: 'Book', type: 'stting'},
                                {name: 'Author', type: 'stting'},
                            ],

                            proxy: {
                                type: 'ajax',
                                url: '/book/list?filter=',
                                reader: {
                                    type: 'json',
                                    root: 'data',
                                    successProperty: 'success'
                                }
                            }
                        },
                        beforeQuery: function(query) {
                            query.combo.getGrid().getSelectionModel().deselectAll();
                            query.combo.store.proxy.extraParams = {                            
                               field:"Name",  
                               type: "string",
                               value: query.combo.rawValue                                
                            };
                            query.combo.store.load();
                            return query;
                        },
                        gridConfig: {
                            columns: [
                                {header: 'Author', dataIndex: 'author', flex: 1, hidden: false},
                                {header: 'Book.', dataIndex: 'book', width: 40, hidden: false},
                                {header: 'Name', dataIndex: 'name', width: 30, hidden: false},
                                {header: 'Price', dataIndex: 'price', width: 40, hidden: false},
                            ],
                            hideHeaders: false,
                            ignoreSelection: false
                        },
                        typeAhead: false,
                        hideTrigger: false,
                        name:'enter',
                        forceSelection: true,
                        width: 500
                    },

Upvotes: 0

Views: 87

Answers (2)

Raydel Miranda
Raydel Miranda

Reputation: 14360

Don't use the url attribute for send params. Use params.

proxy: {
     type: 'ajax',
     url: '/book/list',
     params: {
         filter: "[{field:Name,type:string,value:query}]"
     }
     reader: {
                  type: 'json',
                  root: 'data',
                  successProperty: 'success'
     }
} 

Upvotes: 1

user2721793
user2721793

Reputation: 84

i am not sure what you want, but maybe this is the correct answer!?

proxy = {
  type: 'ajax',
  url: '/book/list?filter=' + JSON.stringify([{
     "field":"Name",
     "type":"string",
     "value":"query"
  }]),
  reader: {
    ....
  }
}

Upvotes: 1

Related Questions