简体   繁体   English

jquery querybuilder:在文件 query-builder.standalone 中编辑规则的结构

[英]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.

相关问题 ASP.Net-MVC的动态查询生成器-使用jQuery QueryBuilder,DataTables和dynamic-linq-query-builder - Dynamic Query Builder for ASP.Net-MVC - Using jQuery QueryBuilder, DataTables, and dynamic-linq-query-builder JQuery QueryBuilder 中的子查询 - Subquery in JQuery QueryBuilder jQuery-QueryBuilder 单击哪个组按钮? - jQuery-QueryBuilder which group button is clicked? 有没有办法将所选的 jQuery Query Builder 过滤器描述为纯文本? - Is there a way to describe the chosen jQuery Query Builder filters as plain text? 类型“ JQuery”上不存在如何删除属性“ queryBuilder” <HTMLElement> “ - How to remove Property 'queryBuilder' does not exist on type 'JQuery<HTMLElement>' 如何将带有ajax的select2添加到jquery查询构建器? - How to add select2 with ajax to jquery query builder? 提交最后一次搜索的 jquery-queryBuilder 初始化规则 - jquery-queryBuilder init rules with last search submitted 是否可以使用 jQuery QueryBuilder 构建包含“XOR”条件的 SQL 语句 - Is it possible to build SQL statements including 'XOR' condition with jQuery QueryBuilder 将 angular2-query-builder 查询转换为逻辑表达式 - Converting angular2-query-builder query to logical expression 使用jQuery Query Builder分别评估表达式 - Evaluating expressions individually using jQuery Query Builder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM