简体   繁体   English

如何更改ExtJS商店代理中extraParams的分隔符?

[英]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 ; 我遇到了与ExtJS商店的extraParams相关的问题。我需要更改默认的params分隔符和自定义; since the web service I'm accessing doesn't respond to &. 因为我正在访问的Web服务没有响应&。

Is there a way to change the separator? 有没有办法改变分隔符?

Bests, Andreas 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. ExtJS没有内置任何东西来允许自定义参数分隔符 - 毕竟使用'&'是事实上的标准。

However, you can change the default behaviour if you need to by overriding Ext.Object.toQueryString 但是,如果需要,可以通过重写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: 我在Sencha论坛上找到了一个解决方法:

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. 使用此行,在加载商店之前,可以绕过extraParams并使用url字段将它们直接传递给使用的代理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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