0

I am using redquerybuilder version 0.6 to create a querybuilder for my application. I downloaded the archive and added the script as per the document. I have a date field to select and query the database. When I select the date field from the field list, the value text is automatically filled with current date value, but the argument will be still null. Also when I change the selected field from date to any other field, the arguments for the current field is updated with date value. Is there any way to set the default value of date field to 'null'. My code is as below:

enter code here

RedQueryBuilderFactory.create({
meta : {
    tables : [ {
        "name" : "artefacts_log2timeline",
        "label" : "Log2Timeline",
        "columns" : [ {
            "name" : "timezone",
            "label" : "Timezone",
            "type" : "STRING"
        }, {
            "name" : "datetime",
            "label" : "date",
            "type" : "DATE",
                            "default" : "",
            "size" : 10
        }, {
            "name" : "source",
            "label" : "Source",
            "type" : "STRING",
            //"editor" : "SELECT"
        }]
      },
onSqlChange : function(sql, args) {
    var out = sql + '\r\n';
            var query_args = '';
    for (var i = 0; i < args.length; i++) {
                    //console.log('Arg'+args);
                    //console.log('Sql'+sql);
        var arg = args[i];
                    if (arg == null || arg == '')
                        arg = ''
                    if(i != 0){
                        query_args+=','
                        /*if(i > 0){
                            if(arg.toString().indexOf('GMT') > -1 || arg == '')
                                arg = ''
                        }*/
                    }

                    //console.log(sql)
        out += 'arg' + i;
        if (arg != null) {
            out += ' type=' + Object.prototype.toString.call(arg) + ' toString=' + arg;
        } else {
            out += ' null';
        }
        out += '\r\n';

                    query_args+='args'+i+'='+arg
    }
    document.getElementById("debug").value = out;
            document.getElementById("args").value= query_args;
            console.log(document.getElementById("args").value)
            //console.log(document.getElementById("debug").value);
},
enumerate : function(request, response) {
    if (request.columnName == 'CATEGORY') {
        response([{value:'A', label:'Small'}, {value:'B', label:'Medium'}]);
    } else {
        response([{value:'M', label:'Male'}, {value:'F', label:'Female'}]);
    }
}]
},'', '');

Thanks in advance.

user12757
  • 39
  • 1
  • 9
  • Hi is there any function like 'onTableChange' that can be used to check if a table field selection is changed? – user12757 Mar 21 '14 at 09:56

1 Answers1

1

Please could you try the 0.7.0.beta here: http://0-7-0.redquerybuilder.appspot.com/ ?

There are two bugs/mistakes interacting here: https://github.com/salk31/RedQueryBuilder/issues/19 https://github.com/salk31/RedQueryBuilder/issues/20

They should both be fixed in 0.7.0

NB This build has only had automated tests. A refactor in there and a new Number editor...

salk31
  • 995
  • 2
  • 8
  • 13