简体   繁体   中英

How do I change the separator of extraParams in an ExtJS store proxy?

I'm stuck with a problem related to the extraParams of an ExtJS store.. I need to change the default params separator & to a customized ; since the web service I'm accessing doesn't respond to &.

Is there a way to change the separator?

Bests, Andreas

There's nothing built in to ExtJS to allow customisation of the parameter separator - the use of '&' is a de-facto standard, after all.

However, you can change the default behaviour if you need to by overriding Ext.Object.toQueryString

Ext.define('Ext.override.CustomQueryString', {
  override: 'Ext.Object',
  toQueryString: function() {
    var queryString = this.callParent(arguments);
    return queryString.replace('&', ':');
  }
})

Something like that would change behaviour globally. This may or may not be a good thing to do.

I found a workaround on the Sencha forums:

yourStore.proxy.url = 'your/url/' + yourParameter + ';.....';

With this line, before loading the store, it's possible to go around the extraParams and still pass them directly to the used proxy using the url field.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM