[英]jquery querybuilder: editing the Rule's structure in the file query-builder.standalone
I created a custom plugin for Jquery Querybuilder but it only works if I edit the Rule's structure from the file querybuilder-standalone itself.我为 Jquery Querybuilder 创建了一个自定义插件,但它只有在我从文件 querybuilder-standalone 本身编辑规则的结构时才有效。
The plugin I've created adds a button like the one from the plugin not-group inside each rule.我创建的插件添加了一个按钮,就像每个规则内的插件非组中的按钮一样。 The function of this plugin is to transform an input like this 'field = "value"' into this 'UPPER( field ) = "VALUE"'.这个插件的功能是将像这样的输入'field = "value"' 转换成这个'UPPER( field ) = "VALUE"'。 The problem with this solution is that, in order to reuse this query I need to modify the structure of the Rule itself in the query-builder.这个解决方案的问题是,为了重用这个查询,我需要在查询构建器中修改规则本身的结构。 The edits I would need to make are the following:我需要进行的编辑如下:
You can find the original code at line 2242 of the file query-builder.standalone.js您可以在文件 query-builder.standalone.js 的第 2242 行找到原始代码
if (model.filter) {
model.filter.to_upper = item.to_upper; /* <---This is the line I added myself */
model.operator = self.getOperatorByType(item.operator, !options.allow_invalid);
if (!model.operator) {
model.operator = self.getOperators(model.filter)[0];
}
}
And this:和这个:
Original code between line 6215 and 6232第 6215 行和 6232 行之间的原始代码
var id = self.getSQLFieldID(field, value);
//The following line us the code I need
var to_upper = data.to_upper;
/**
* Modifies the rule generated from the SQL expression
* @event changer:sqlToRule
* @memberof module:plugins.SqlSupport
* @param {object} rule
* @param {object} AST
* @returns {object}
*/
var rule = self.change('sqlToRule', {
id: id,
field: field,
operator: opVal.op,
value: opVal.val,
//The following line us the code I need
to_upper: to_upper
}, data);
'to_upper' is a property I set to false by default and to true when its related button it's clicked. 'to_upper' 是我默认设置为 false 的属性,并在单击其相关按钮时设置为 true。
How could I do this without adding these code to query-builder itself?如果不将这些代码添加到查询构建器本身,我怎么能做到这一点?
Here you can find more details about my issue and the helpful answer I received from the creator of this UI component.在这里您可以找到有关我的问题的更多详细信息以及我从该 UI 组件的创建者那里收到的有用答案。 https://github.com/mistic100/jQuery-QueryBuilder/issues/931 https://github.com/mistic100/jQuery-QueryBuilder/issues/931
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.