Prepopulate Expression Grid with partially populated rows

Answered

Comments

17 comments

  • Avatar
    Sergey Smagin (Product manager)

    Hello,

    Unfortunately it is not possible to do what you want. Of course, you can use JavaScript API of Active Query Builder ASP.NET edition 2.0 to create your own control, but it's not an easy task.

    What we can suggest is to change the Alias column from simple text edit box to combobox and prepopulate it with the list of values you need. The weak point is that user can select duplicate values or not to select them at all. Do you need such customization?

    0
    Comment actions Permalink
  • Avatar
    Simon

    That was exactly my question in my other thread and I was told this was not possible:

    http://feedback.activequerybuilder.com/topics/159-dropbown-box-in-column-name-field/

    Yes, if possible that would be a great solution actually.

    0
    Comment actions Permalink
  • Avatar
    Denis Shundeev

    The new version 2.10.14 implements new event QB.Web.Application.GridComponent.CustomEditControl.

    Usage sample:

        <script>
            OnApplicationReady(function () {
                QB.Web.Application.GridComponent.CustomEditControl = function(key, cell, row) {
                    var control = null;
                    if (key == MetaData.FieldParamType.alias) {
                        var values = ["alias1", "alias2", "alias3", "alias4"];
                        control = $('<select>');
                        values.forEach(function(val, i){
                            $('<option value="'+val+'">'+val+'</option>').appendTo(control);
                        })
                    }
                    return control;
                }
            });
        </script>
    
    0
    Comment actions Permalink
  • Avatar
    Simon

    I am not able to get this to work, could you please give me more context?

    1. Which sample can I dump this in ?
    2. In which file exactly?
    3. Do I paste it as is or do I need to rename something?

    Also: will it work in the trial version?

    Thank you,

    Simon

    0
    Comment actions Permalink
  • Avatar
    Simon

    I couldn't edit, so I am updating question here (ignore previous one).

    Question 1:

    I am not able to get this to work, could you please give me more context?

    1. Which sample can I dump this in ?
    2. In which file exactly?
    3. Do I paste it as is or do I need to rename something?

    Question 2:

    The sample code you provided on 03/04 adds option elements to en existing select element. Does this mean that the code only works where a select element already exists ? But the alias column does not have a combo. I am confused.

    Question 3:

    Will it work in the trial version since aliases are disabled?

    Thank you,

    Simon

    0
    Comment actions Permalink
  • Hello, Simon.

    Sorry for the late response. These days are holidays in Russia, so we couldn't answer promptly. We'll get back to work on 03/09.

    Q1:

    As far as I can see this code is intended to be pasted to the source code of your web page containing Active Query Builder. You don't need to change anything in this code except the list of values for alias.

    Q2:

    The sample code you provided on 03/04 adds option elements to en existing select element.

    No, it is not correct. The options are added to the newly created <select> element:

    Creating select:

    control = $('<select>');

    Adding elements to it:

    $('<option value="'+val+'">'+val+'</option>').appendTo(control);

    Returning it for use in a cell:

    return control;

    This event will be fired each time a new row is added to the Query Column List.

    Q3:

    Yes, it will work: you will see a combo box in the Alias cell. But after selecting a value, it won't be applied to the query, but replaced with random alias. This is the limitation of the trial version.

    PS: The most probable reason why this code doesn't work is that you didn't updated Active Query Builder in your project to the latest version. Please install the latest version 2.10.14, open your project, in the References section make sure that versions of ActiveDatabaseSoftware.ActiveQueryBuilder.Web.* assemblies are of the latest version, then replace the necessary .js and .css files with the latest ones, clean and rebuild your project.

    0
    Comment actions Permalink
  • Avatar
    Simon

    Thank you for all the answers but unfortunately it's still not working.

    1. I had completely uninstalled the old version and installed 2.10.14 before trying
    2. The ActiveDatabaseSoftware.ActiveQueryBuilder.Web.* assemblies correctly point to 2.10.14
    3. I can step into the JS code and I don't see any errors

    The alias column (I assume that is "Column Name") is not a combo box.

    This is the code I am using. I modified the Default.aspx file of the "Client event handle" sample:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Samples.Default" %>
    <%@ Register TagPrefix="uc" TagName="QueryBuilderUC" Src="ClientEventHandle.ascx" %>
    
    <!DOCTYPE html>
    <html>
    <head id="Head1" runat="server">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>ActiveQueryBilder ASP.NET - Simple Offline Demo</title>
        <link href="jquery.jgrowl.css" type="text/css" rel="stylesheet" />
        <style type="text/css">
    
    	</style>
    </head>
    <body>
        <script type="text/javascript" language="javascript" src="jquery.jgrowl.js"></script>
        <script type="text/javascript" language="javascript">
            //OnApplicationReady(function () {
            //	QB.Web.Application.Canvas.bind(QB.Web.Canvas.Events.CanvasOnAddTable, onAddTableToCanvas);
            //	QB.Web.Core.bind(QB.Web.Core.Events.DataSending, beforeDataExchange);
            //	QB.Web.Core.bind(QB.Web.Core.Events.DataReceived, afterDataExchange);
            //});
    
            OnApplicationReady(function () {
                QB.Web.Application.GridComponent.CustomEditControl = function (key, cell, row) {
                    var control = null;
                    if (key == MetaData.FieldParamType.alias) {
                        var values = ["alias1", "alias2", "alias3", "alias4"];
                        control = $('<select>');
                        values.forEach(function (val, i) {
                            $('<option value="' + val + '">' + val + '</option>').appendTo(control);
                        })
                    }
                    return control;
                }
            });
    
            function beforeDataExchange(e, data) {
                $.jGrowl("Before data exchange", { header: 'Core event' });
            }
    
            function afterDataExchange(e, data) {
                $.jGrowl("After data exchange", { header: 'Core event' });
            }
    
            function onAddTableToCanvas(sender, e) {
                $.jGrowl("Add table to canvas", { header: 'Canvas event' });
            }
        </script>
        <form id="Form1" runat="server">
            <uc:QueryBuilderUC ID="QueryBuilderUC1" runat="server" />
        </form>
    </body>
    </html>
    


    0
    Comment actions Permalink
  • Thank you for detailed report.

    We will investigate the problem and let you know about result tomorrow.

    0
    Comment actions Permalink
  • Avatar
    Denis Shundeev

    Hello, Simon.

    Indeed, we've found that this code doesn't work in the current version, even it's technically possible make it work. Please accept my apologies for this mistake.

     

    0
    Comment actions Permalink
  • Avatar
    Simon

    Still not working...

    I uninstalled 2.10.14 Trial and installed 2.10.14 Free.

    I am trying to work with the "Client event handle" sample, but without adding any of the new code it doesn't run.

    I want to load the XML just like the Trial version does. So I copied:

    queryBuilder.MetadataContainer.ImportFromXML(Page.Server.MapPath(ConfigurationManager.AppSettings["XmlMetaData"]));

    But this causes a compile error:

    'QueryBuilder' does not contain a definition for 'MetadataContainer' and no extension method 'MetadataContainer' accepting a first argument of type 'QueryBuilder' could be found

    So I tried to load a connection instead using:

    System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection{
    	ConnectionString = ConfigurationManager.ConnectionStrings["Northwind"].ConnectionString
    };

    But then I get

    An OLE DB Provider was not specified in the ConnectionString. An example would be, 'Provider=SQLOLEDB;'.

    I tried adding my Provider to the connection string (which should not be needed anyway) and it still doesn't work.

    Can you please send me code that works? I have installed 5 different releases and spend a month on this very simple project.

    Thank you

    0
    Comment actions Permalink
  • Hello, Simon.

    Please accept my apologies for the inconveniences this problem caused you.

    Indeed, the ability to load metadata from XML is missing in Free version. But the sample project that I've sent to you works fine with the free version. The problem with incorrect handling of OLE DB connection strings should be reported to Microsoft, I think.



    0
    Comment actions Permalink
  • Avatar
    Simon

    Is the XML feature present in the full license?

    All I need is sample code with a working connection string, if you could please send that maybe I canfigure out why mine is not working.

    0
    Comment actions Permalink
  • Avatar
    Sergey Smagin (Product manager)

    Hello, Simon.

    Yes, the "full version" means that all possible features are present in it, including the XML feature.

    You can use the "Simple Offline demo" with the full version, or the "Simple OLE DB Demo" with the free or full version, and just add the mentioned JavaScript code to it. 

    Sorry, but I don't know what is your database server, what are the other connection props, so I can't provide the right connection string for you. All you need to do is to establish a connection to your database the way you know (aren't you did that before using Active Query Builder?), and then pass this connecion object to Active Query Builder:

    OLE DB Connection is not the only possible DB Connection type to work with Active Query Builder. You can use SqlConnection for MS SQL Server, you can use ODBC connection for different types of servers: Active Query Builder provides special Metadata Provider objects for these types of connections: OleDbMetadataProvider - for OleDbConnection, OdbcMetadataProvider - for OdbcConnection, MsSqlMetadataProvider for SqlConnection. Different types of DB connections accept different formats of connection strings. Please establish connection to your database in a project that doesn't have Active Query Builder at all, then copy this code to the Init handler, and it will work.

    0
    Comment actions Permalink
  • Avatar
    Simon

    I appreciate the special demo, but my issue is with the SQL connection. They way I got it to work with older versions is using:

    queryBuilder.MetadataProvider = new MSSQLMetadataProvider { Connection = connection };
    

    This does not work anymore. I get a compile error:

    The type or namespace name 'MSSQLMetadataProvider' could not be found (are you missing a using directive or an assembly reference?)

    Was MSSQLMetadataProvider removed?

    Also I installed the Full version (thank you). But when I try to activate I get:

    License with such registration key is not found.
    If you feel this is wrong, please contact us to investigate this problem.

    However as far as I can tell it seems to work.

    0
    Comment actions Permalink
  • Hello, Simon.

    I've just installed the full version (using the link that I gave you in my previous message), and I've found that the "ActiveDatabaseSoftware.MSSQLMetadataProvider2.dll" file is located exactly where it should be (in "c:\Program Files\ActiveDBSoft\Active Query Builder 2 ASP.NET Edition\assemblies\.NET 2.0\" folder). So it isn't removed. I think that you just have to update the references in your project.

    It's not a problem that the key is not found: it's like a 30-day trial of the full version.


    0
    Comment actions Permalink
  • Avatar
    Simon

    1) OK, I got rid of the compile error, thank you. The reason it's confusing is that the namespace of MSSQLMetadataProvider is ActiveDatabaseSoftware.ActiveQueryBuilder. It's hard to figure out that a reference to ActiveDatabaseSoftware.MSSQLMetadataProvider2.dll is also needed. Anyway that works.

    2) The following line was also missing from the Simple OLE DB Demo:
    queryBuilder.SyntaxProvider = new MSSQLSyntaxProvider();

    Once I added that I was finally able to see the combo box using the connection string!

    0
    Comment actions Permalink
  • Glad to know that the problem is solved.

    Should you have any other questions, please do not hesitate to ask.

    0
    Comment actions Permalink

Please sign in to leave a comment.