Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with recurssion #8

Open
gantir opened this issue Nov 26, 2013 · 0 comments
Open

Issue with recurssion #8

gantir opened this issue Nov 26, 2013 · 0 comments

Comments

@gantir
Copy link
Owner

gantir commented Nov 26, 2013

While I was using it I found that when you go deep to 3 or more nested condition the result query became false (nested condition of nested condition are repeted more than needed).

I think you abandoned this project, that why I emailed you.
I was wondering if you could gave me a clue for how to solve this issue and as soon as I solve it I will share it.

The issue may be in the recursive method to parse the condition and generate the query:

var getCondition = function (rootsel) {
//Get the columns from table (to find a clean way to do it later) //tbody>tr>td
var elem = $(rootsel).children().children().children();
//elem 0 is for operator, elem 1 is for expressions

var q = {};
var expressions = [];
var nestedexpressions = [];

var operator = $(elem[0]).find(':selected').val();
q.operator = operator;

// Get all the expressions in a condition
var expressionelem = $(elem[1]).find('> .querystmts div');
for (var i = 0; i < expressionelem.length; i++) {
    expressions[i] = {};
    var col = $(expressionelem[i]).find('.col :selected');
    var op = $(expressionelem[i]).find('.op :selected');
    expressions[i].colval = col.val();
    expressions[i].coldisp = col.text();
    expressions[i].opval = op.val();
    expressions[i].opdisp = op.text();
    expressions[i].val = $(expressionelem[i]).find(':text').val();
}
q.expressions = expressions;

// Get all the nested expressions
if ($(elem[1]).find('table').length != 0) {
    var len = $(elem[1]).find('table').length;
    alert(len);
    for (var k = 0; k < len; k++) {
        nestedexpressions[k] = getCondition($(elem[1]).find('table')[k]);
    } 
}
q.nestedexpressions = nestedexpressions;

return q;

};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant